var Jt=Object.create;var Le=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var ct=s=>{throw TypeError(s)};var ei=(s,e,t)=>e in s?Le(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var lt=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var ti=(s,e)=>{for(var t in e)Le(s,t,{get:e[t],enumerable:!0})},ii=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Xt(e))!Zt.call(s,r)&&r!==t&&Le(s,r,{get:()=>e[r],enumerable:!(i=Yt(e,r))||i.enumerable});return s};var ut=(s,e,t)=>(t=s!=null?Jt(Qt(s)):{},ii(e||!s||!s.__esModule?Le(t,"default",{value:s,enumerable:!0}):t,s));var d=(s,e,t)=>ei(s,typeof e!="symbol"?e+"":e,t),ht=(s,e,t)=>e.has(s)||ct("Cannot "+t);var f=(s,e,t)=>(ht(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?ct("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),C=(s,e,t,i)=>(ht(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t);var ee=(s,e,t,i)=>({set _(r){C(s,e,r,t)},get _(){return f(s,e,i)}});var c,ri=(c=class{constructor(e,t,i){d(this,"version","7.5.0-src");d(this,"sanitiseExtraTags",["uib-var"]);d(this,"sanitiseExtraAttribs",["variable","report","undefined"]);d(this,"ui_md_plugins");if(e)c.win=e;else throw new Error("Ui:constructor. Current environment does not include `window`, UI functions cannot be used.");c.doc=c.win.document,t?c.log=t:c.log=function(){return function(){}},i?this.syntaxHighlight=i:this.syntaxHighlight=function(){},c.win.markdownit&&(c.mdOpts={html:!0,xhtmlOut:!1,linkify:!0,_highlight:!0,_strict:!1,_view:"html",langPrefix:"language-",highlight:function(r,n){if(n&&window.hljs&&window.hljs.getLanguage(n))try{return'<pre class="">\n                                    <code class="hljs border">'.concat(window.hljs.highlight(r,{language:n,ignoreIllegals:!0}).value,"</code></pre>")}finally{}return'<pre class="hljs border"><code>'.concat(c.md.utils.escapeHtml(r).trim(),"</code></pre>")}},c.md=c.win.markdownit(c.mdOpts))}_markDownIt(){if(c.win.markdownit&&(!this.ui_md_plugins&&c.win.uibuilder&&c.win.uibuilder.ui_md_plugins&&(this.ui_md_plugins=c.win.uibuilder.ui_md_plugins),c.mdOpts={html:!0,xhtmlOut:!1,linkify:!0,_highlight:!0,_strict:!1,_view:"html",langPrefix:"language-",highlight:function(e,t){if(window.hljs)if(t&&window.hljs.getLanguage(t))try{return'<pre><code class="hljs border language-'.concat(t,'" data-language="').concat(t,'" title="Source language: \'').concat(t,"'\">").concat(window.hljs.highlight(e,{language:t,ignoreIllegals:!0}).value,"</code></pre>")}finally{}else try{let i=window.hljs.highlightAuto(e);return'<pre><code class="hljs border language-'.concat(i.language,'" data-language="').concat(i.language,'" title="Source language estimated by HighlightJS: \'').concat(i.language,"'\">").concat(i.value,"</code></pre>")}finally{}return'<pre><code class="border">'.concat(c.md.utils.escapeHtml(e).trim(),"</code></pre>")}},c.md=c.win.markdownit(c.mdOpts),this.ui_md_plugins)){if(!Array.isArray(this.ui_md_plugins)){c.log("error","Ui:_markDownIt:plugins","Could not load plugins, ui_md_plugins is not an array")();return}this.ui_md_plugins.forEach(e=>{if(typeof e=="string")c.md.use(c.win[e]);else{let t=Object.keys(e)[0];c.md.use(c.win[t],e[t])}})}}_showNotification(e){e.topic&&!e.title&&(e.title=e.topic),e.title||(e.title="uibuilder notification"),e.payload&&!e.body&&(e.body=e.payload),e.body||(e.body=" No message given.");try{let t=new Notification(e.title,e);return new Promise((i,r)=>{t.addEventListener("close",n=>{n.currentTarget.userAction="close",i(n)}),t.addEventListener("click",n=>{n.currentTarget.userAction="click",i(n)}),t.addEventListener("error",n=>{n.currentTarget.userAction="error",r(n)})})}catch{return Promise.reject(new Error("Browser refused to create a Notification"))}}_uiAdd(e,t){c.log("trace","Ui:_uiManager:add","Starting _uiAdd")(),e.components.forEach((i,r)=>{c.log("trace","Ui:_uiAdd:components-forEach:".concat(r),"Component to add: ",i)();let n;switch(i.type){case"html":{i.ns="html",n=c.doc.createElement("div");break}case"svg":{i.ns="svg",n=c.doc.createElementNS("http://www.w3.org/2000/svg","svg");break}default:{i.ns="dom",n=c.doc.createElement(i.type);break}}!i.slot&&e.payload&&(i.slot=e.payload),this._uiComposeComponent(n,i);let o;i.parentEl?o=i.parentEl:e.parentEl?o=e.parentEl:i.parent?o=c.doc.querySelector(i.parent):e.parent&&(o=c.doc.querySelector(e.parent)),o||(c.log("info","Ui:_uiAdd","No parent found, adding to body")(),o=c.doc.querySelector("body")),i.position&&i.position==="first"?o.insertBefore(n,o.firstChild):i.position&&Number.isInteger(Number(i.position))?o.insertBefore(n,o.children[i.position]):o.appendChild(n),i.components&&this._uiExtendEl(n,i.components,i.ns)})}_uiComposeComponent(e,t){t.attributes&&Object.keys(t.attributes).forEach(i=>{i==="class"&&Array.isArray(t.attributes[i])&&t.attributes[i].join(" "),c.log("trace","_uiComposeComponent:attributes-forEach","Attribute: '".concat(i,"', value: '").concat(t.attributes[i],"'"))(),i==="value"&&(e.value=t.attributes[i]),i.startsWith("xlink:")?e.setAttributeNS("http://www.w3.org/1999/xlink",i,t.attributes[i]):e.setAttribute(i,t.attributes[i])}),t.id&&e.setAttribute("id",t.id),t.type==="svg"&&(e.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns","http://www.w3.org/2000/svg"),e.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink")),t.events&&Object.keys(t.events).forEach(i=>{i.toLowerCase==="onclick"&&(i="click");try{e.addEventListener(i,r=>{new Function("evt","".concat(t.events[i],"(evt)"))(r)})}catch(r){c.log("error","Ui:_uiComposeComponent","Add event '".concat(i,"' for element '").concat(t.type,"': Cannot add event handler. ").concat(r.message))()}}),t.properties&&Object.keys(t.properties).forEach(i=>{e[i]=t.properties[i],["value","checked"].includes(i)&&(e.dispatchEvent(new Event("input")),e.dispatchEvent(new Event("change")))}),t.slot&&this.replaceSlot(e,t.slot),t.slotMarkdown&&this.replaceSlotMarkdown(e,t)}_uiExtendEl(e,t,i=""){t.forEach((r,n)=>{c.log("trace","Ui:_uiExtendEl:components-forEach:".concat(n),r)();let o;r.ns=i,r.ns==="html"?(o=e,this.replaceSlot(e,r.slot)):r.ns==="svg"?(o=c.doc.createElementNS("http://www.w3.org/2000/svg",r.type),this._uiComposeComponent(o,r),e.appendChild(o)):(o=c.doc.createElement(r.type==="html"?"div":r.type),this._uiComposeComponent(o,r),e.appendChild(o)),r.components&&this._uiExtendEl(o,r.components,r.ns)})}_uiLoad(e){e.components&&(Array.isArray(e.components)||(e.components=[e.components]),e.components.forEach(async t=>{Promise.resolve().then(()=>ut(lt(t)))})),e.srcScripts&&(Array.isArray(e.srcScripts)||(e.srcScripts=[e.srcScripts]),e.srcScripts.forEach(t=>{this.loadScriptSrc(t)})),e.txtScripts&&(Array.isArray(e.txtScripts)||(e.txtScripts=[e.txtScripts]),this.loadScriptTxt(e.txtScripts.join("\n"))),e.srcStyles&&(Array.isArray(e.srcStyles)||(e.srcStyles=[e.srcStyles]),e.srcStyles.forEach(t=>{this.loadStyleSrc(t)})),e.txtStyles&&(Array.isArray(e.txtStyles)||(e.txtStyles=[e.txtStyles]),this.loadStyleTxt(e.txtStyles.join("\n")))}_uiManager(e){e._ui&&(Array.isArray(e._ui)||(e._ui=[e._ui]),e._ui.forEach((t,i)=>{if(t.mode&&!t.method&&(t.method=t.mode),!t.method){c.log("error","Ui:_uiManager","No method defined for msg._ui[".concat(i,"]. Ignoring. "),t)();return}switch(t.payload=e.payload,t.topic=e.topic,t.method){case"add":{this._uiAdd(t,!1);break}case"remove":{this._uiRemove(t,!1);break}case"removeAll":{this._uiRemove(t,!0);break}case"replace":{this._uiReplace(t);break}case"update":{this._uiUpdate(t);break}case"load":{this._uiLoad(t);break}case"reload":{this._uiReload();break}case"notify":{this.showDialog("notify",t,e);break}case"alert":{this.showDialog("alert",t,e);break}default:{c.log("error","Ui:_uiManager","Invalid msg._ui[".concat(i,"].method (").concat(t.method,"). Ignoring"))();break}}}))}_uiReload(){c.log("trace","Ui:uiManager:reload","reloading")(),location.reload()}_uiRemove(e,t=!1){e.components.forEach(i=>{let r;t!==!0?r=[c.doc.querySelector(i)]:r=c.doc.querySelectorAll(i),r.forEach(n=>{try{n.remove()}catch(o){c.log("trace","Ui:_uiRemove","Could not remove. ".concat(o.message))()}})})}_uiReplace(e){c.log("trace","Ui:_uiReplace","Starting")(),e.components.forEach((t,i)=>{c.log("trace","Ui:_uiReplace:components-forEach:".concat(i),"Component to replace: ",t)();let r;if(t.id?r=c.doc.getElementById(t.id):t.selector||t.select?r=c.doc.querySelector(t.selector):t.name?r=c.doc.querySelector('[name="'.concat(t.name,'"]')):t.type&&(r=c.doc.querySelector(t.type)),c.log("trace","Ui:_uiReplace:components-forEach:".concat(i),"Element to replace: ",r)(),r==null){c.log("trace","Ui:_uiReplace:components-forEach:".concat(i,":noReplace"),"Cannot find the DOM element. Adding instead.",t)(),this._uiAdd({components:[t]},!1);return}let n;switch(t.type){case"html":{t.ns="html",n=c.doc.createElement("div");break}case"svg":{t.ns="svg",n=c.doc.createElementNS("http://www.w3.org/2000/svg","svg");break}default:{t.ns="dom",n=c.doc.createElement(t.type);break}}this._uiComposeComponent(n,t),r.replaceWith(n),t.components&&this._uiExtendEl(n,t.components,t.ns)})}_uiUpdate(e){c.log("trace","UI:_uiUpdate:update","Starting _uiUpdate",e)(),e.components||(e.components=[Object.assign({},e)]),e.components.forEach((t,i)=>{c.log("trace","_uiUpdate:components-forEach","Start loop #".concat(i),t)();let r;if(t.parentEl?r=t.parentEl:t.id?r=c.doc.querySelectorAll("#".concat(t.id)):t.selector||t.select?r=c.doc.querySelectorAll(t.selector):t.name?r=c.doc.querySelectorAll('[name="'.concat(t.name,'"]')):t.type&&(r=c.doc.querySelectorAll(t.type)),r===void 0||r.length<1){c.log("warn","Ui:_uiManager:update","Cannot find the DOM element. Ignoring.",t)();return}c.log("trace","_uiUpdate:components-forEach","Element(s) to update. Count: ".concat(r.length),r)(),!t.slot&&t.payload&&(t.slot=t.payload),r.forEach((n,o)=>{if(c.log("trace","_uiUpdate:components-forEach","Updating element #".concat(o),n)(),this._uiComposeComponent(n,t),t.components){c.log("trace","_uiUpdate:nested-component","Element #".concat(o," - nested-component"),t,n)();let a={_ui:[]};t.components.forEach((u,h)=>{let p=u.method||t.method||e.method;u.method&&delete u.method,Array.isArray(u)||(u=[u]),c.log("trace","_uiUpdate:nested-component","Element #".concat(o," - nested-component #").concat(h),u)(),a._ui.push({method:p,parentEl:n,components:u})}),c.log("trace","_uiUpdate:nested-component","Element #".concat(o," - nested-component new manager"),a)(),this._uiManager(a)}})})}$(e,t,i){if(i||(i=c.doc),t||(t="el"),!i||!i.nodeType)return c.log(1,"Uib:$","Invalid context element. Must be a valid HTML element.",i)(),null;let r=i.querySelector(e);if(!r||!r.nodeType)return c.log(1,"Uib:$","No element found or element is not an HTML element for CSS selector ".concat(e))(),null;if(r.nodeName==="TEMPLATE"&&(r=r.content.firstElementChild,!r))return c.log(0,"Uib:$","Template selected for CSS selector ".concat(e," but it is empty"))(),null;let n;try{switch(t.toLowerCase()){case"text":{n=r.innerText;break}case"html":{n=r.innerHTML;break}case"attr":case"attributes":{n={};for(let o of r.attributes)n[o.name]=o.value;break}default:{n=r;break}}}catch(o){n=r,c.log(1,"Uib:$",'Could not process output type "'.concat(t,'" for CSS selector ').concat(e,", returned the DOM element. ").concat(o.message),o)()}return n}$$(e,t){return t||(t=c.doc),!t||!t.nodeType?(c.log(1,"Uib:$$","Invalid context element. Must be a valid HTML element.",t)(),null):Array.from(t.querySelectorAll(e))}addClass(e,t){Array.isArray(e)||(e=[e]),t&&t.classList.add(...e)}applyTemplate(e,t,i){var u;i||(i={}),i.onceOnly||(i.onceOnly=!1),i.mode||(i.mode="insert");let r=c.doc.getElementById(e);if(!r||r.tagName!=="TEMPLATE"){c.log("error","Ui:applyTemplate","Source must be a <template>. id='".concat(e,"'"))();return}let n=c.doc.getElementById(t);if(!n){c.log("error","Ui:applyTemplate","Target not found: id='".concat(t,"'"))();return}let o=(u=n.innerHTML)!=null?u:"";o&&i.mode==="replace"&&c.log("warn","Ui:applyTemplate","Target element is not empty, content is replaced. id='".concat(t,"'"))();let a;if(i.onceOnly===!0?a=c.doc.adoptNode(r.content):a=c.doc.importNode(r.content,!0),a){if(i.attributes){let h=a.firstElementChild;Object.keys(i.attributes).forEach(p=>{h.setAttribute(p,i.attributes[p])})}if(i.mode==="insert")n.appendChild(a);else if(i.mode==="replace")n.innerHTML="",n.appendChild(a);else if(i.mode==="wrap"&&(n.innerHTML="",n.appendChild(a),o)){let h=n.getElementsByTagName("slot");h.length>0&&(h[0].innerHTML=o)}}else c.log("warn","Ui:applyTemplate","No valid content found in template")()}convertMarkdown(e){if(!e)return"";if(!c.win.markdownit)return e;c.md||this._markDownIt();try{return c.md.render(e.trim())}catch(t){return c.log(0,"uibuilder:convertMarkdown","Could not render Markdown. ".concat(t.message),t)(),'<p class="border error">Could not render Markdown<p>'}}async include(e,t){if(!fetch)return c.log(0,"Ui:include","Current environment does not include `fetch`, skipping.")(),"Current environment does not include `fetch`, skipping.";if(!e)return c.log(0,"Ui:include","url parameter must be provided, skipping.")(),"url parameter must be provided, skipping.";if(!t||!t.id)return c.log(0,"Ui:include","uiOptions parameter MUST be provided and must contain at least an `id` property, skipping.")(),"uiOptions parameter MUST be provided and must contain at least an `id` property, skipping.";let i;try{i=await fetch(e)}catch(h){return c.log(0,"Ui:include","Fetch of file '".concat(e,"' failed. "),h.message)(),h.message}if(!i.ok)return c.log(0,"Ui:include","Fetch of file '".concat(e,"' failed. Status='").concat(i.statusText,"'"))(),i.statusText;let r=await i.headers.get("content-type"),n=null;r&&(r.includes("text/html")?n="html":r.includes("application/json")?n="json":r.includes("multipart/form-data")?n="form":r.includes("image/")?n="image":r.includes("video/")?n="video":r.includes("application/pdf")?n="pdf":r.includes("text/plain")&&(n="text"));let o="",a="Include successful",u;switch(n){case"html":{u=await i.text(),o=u;break}case"json":{u=await i.json(),o='<pre class="syntax-highlight">',o+=this.syntaxHighlight(u),o+="</pre>";break}case"form":{u=await i.formData(),o='<pre class="syntax-highlight">',o+=this.syntaxHighlight(u),o+="</pre>";break}case"image":{u=await i.blob(),o='<img src="'.concat(URL.createObjectURL(u),'">'),c.win.DOMPurify&&(a="Include successful. BUT DOMPurify loaded which may block its use.",c.log("warn","Ui:include:image",a)());break}case"video":{u=await i.blob(),o='<video controls autoplay><source src="'.concat(URL.createObjectURL(u),'"></video>'),c.win.DOMPurify&&(a="Include successful. BUT DOMPurify loaded which may block its use.",c.log("warn","Ui:include:video",a)());break}case"pdf":case"text":default:{u=await i.blob(),o='<iframe style="resize:both;width:inherit;height:inherit;" src="'.concat(URL.createObjectURL(u),'">'),c.win.DOMPurify&&(a="Include successful. BUT DOMPurify loaded which may block its use.",c.log("warn","Ui:include:".concat(n),a)());break}}return t.type="div",t.slot=o,t.parent||(t.parent="body"),t.attributes||(t.attributes={class:"included"}),this._uiReplace({components:[t]}),c.log("trace","Ui:include:".concat(n),a)(),a}loadScriptSrc(e){let t=c.doc.createElement("script");t.src=e,t.async=!1,c.doc.head.appendChild(t)}loadScriptTxt(e){let t=c.doc.createElement("script");t.async=!1,t.textContent=e,c.doc.head.appendChild(t)}loadStyleSrc(e){let t=c.doc.createElement("link");t.href=e,t.rel="stylesheet",t.type="text/css",c.doc.head.appendChild(t)}loadStyleTxt(e){let t=c.doc.createElement("style");t.textContent=e,c.doc.head.appendChild(t)}loadui(e){if(!fetch){c.log(0,"Ui:loadui","Current environment does not include `fetch`, skipping.")();return}if(!e){c.log(0,"Ui:loadui","url parameter must be provided, skipping.")();return}fetch(e).then(t=>{if(t.ok===!1)throw new Error("Could not load '".concat(e,"'. Status ").concat(t.status,", Error: ").concat(t.statusText));c.log("trace","Ui:loadui:then1","Loaded '".concat(e,"'. Status ").concat(t.status,", ").concat(t.statusText))();let i=t.headers.get("content-type");if(!i||!i.includes("application/json"))throw new TypeError("Fetch '".concat(e,"' did not return JSON, ignoring"));return t.json()}).then(t=>t!==void 0?(c.log("trace","Ui:loadui:then2","Parsed JSON successfully obtained")(),this._uiManager({_ui:t}),!0):!1).catch(t=>{c.log("warn","Ui:loadui:catch","Error. ",t)()})}moveElement(e){let{sourceSelector:t,targetSelector:i,moveType:r,position:n}=e;if(!document.querySelector(t)){c.log(0,"Ui:moveElement","Source element not found")();return}if(!document.querySelector(i)){c.log(0,"Ui:moveElement","Target element not found")();return}}nodeGet(e,t){let i={id:e.id===""?void 0:e.id,name:e.name,children:e.childNodes.length,type:e.nodeName,attributes:void 0,isUserInput:!!e.validity,userInput:e.validity?{value:e.value,validity:void 0,willValidate:e.willValidate,valueAsDate:e.valueAsDate,valueAsNumber:e.valueAsNumber,type:e.type}:void 0};if(["UL","OL"].includes(e.nodeName)){let r=c.doc.querySelectorAll("".concat(t," li"));r&&(i.list={entries:r.length})}if(e.nodeName==="DL"){let r=c.doc.querySelectorAll("".concat(t," dt"));r&&(i.list={entries:r.length})}if(e.nodeName==="TABLE"){let r=c.doc.querySelectorAll("".concat(t," > tbody > tr")),n=c.doc.querySelectorAll("".concat(t," > thead > tr")),o=c.doc.querySelectorAll("".concat(t," > tbody > tr:last-child > *"));(r||n||o)&&(i.table={headRows:n?n.length:0,bodyRows:r?r.length:0,columns:o?o.length:0})}if(e.nodeName!=="#text"&&e.attributes&&e.attributes.length>0){i.attributes={};for(let r of e.attributes)r.name!=="id"&&(i.attributes[r.name]=e.attributes[r.name].value),r.name==="class"&&(i.classes=Array.from(e.classList))}e.nodeName==="#text"&&(i.text=e.textContent),e.validity&&(i.userInput.validity={});for(let r in e.validity)i.userInput.validity[r]=e.validity[r];return i}async notification(e){if(typeof e=="string"&&(e={body:e}),typeof Notification>"u")return Promise.reject(new Error("Notifications not available in this browser"));let t=Notification.permission;return t==="denied"?Promise.reject(new Error("Notifications not permitted by user")):t==="granted"?this._showNotification(e):(t=await Notification.requestPermission(),t==="granted"?this._showNotification(e):Promise.reject(new Error("Notifications not permitted by user")))}removeClass(e,t){if(!e){t.removeAttribute("class");return}Array.isArray(e)||(e=[e]),t&&t.classList.remove(...e)}replaceSlot(e,t){if(!e)return;t||(t=""),t=this.sanitiseHTML(t);let i=c.doc.createRange().createContextualFragment(t),r=c.doc.createRange();r.selectNodeContents(e),r.deleteContents(),e.append(i)}replaceSlotMarkdown(e,t){e&&t.slotMarkdown&&(t.slotMarkdown=this.convertMarkdown(t.slotMarkdown),t.slotMarkdown=this.sanitiseHTML(t.slotMarkdown),e.innerHTML=t.slotMarkdown)}sanitiseHTML(e){return c.win.DOMPurify?c.win.DOMPurify.sanitize(e,{ADD_TAGS:this.sanitiseExtraTags,ADD_ATTR:this.sanitiseExtraAttribs}):e}showDialog(e,t,i){(!e||!["notify","alert"].includes(e))&&(e="notify"),t||(t={noAutohide:!0,modal:!0,appendToast:!1});let r="";if(i.payload&&typeof i.payload=="string"&&(r+="<div>".concat(i.payload,"</div>")),t.content&&(r+="<div>".concat(t.content,"</div>")),r==="")return c.log(1,"Ui:showDialog","Toast content is blank. Not shown.")(),null;let n="";t.title?n=t.title:i.topic&&(n=i.topic),t.noAutohide&&(t.noAutoHide=t.noAutohide),t.noAutoHide&&(t.autohide=!t.noAutoHide),t.autoHideDelay?(t.autohide||(t.autohide=!0),t.delay=t.autoHideDelay):t.autoHideDelay=1e4,Object.prototype.hasOwnProperty.call(t,"autohide")||(t.autohide=!0);let o="",a="";e==="alert"&&(a='<svg viewBox="0 0 192.146 192.146"><path d="M108.186 144.372c0 7.054-4.729 12.32-12.037 12.32h-.254c-7.054 0-11.92-5.266-11.92-12.32 0-7.298 5.012-12.31 12.174-12.31s11.91 4.992 12.037 12.31zM88.44 125.301h15.447l2.951-61.298H85.46l2.98 61.298zm101.932 51.733c-2.237 3.664-6.214 5.921-10.493 5.921H12.282c-4.426 0-8.51-2.384-10.698-6.233a12.34 12.34 0 0 1 .147-12.349l84.111-149.22c2.208-3.722 6.204-5.96 10.522-5.96h.332c4.445.107 8.441 2.618 10.513 6.546l83.515 149.229c1.993 3.8 1.905 8.363-.352 12.066zm-10.493-6.4L96.354 21.454l-84.062 149.18h167.587z" /></svg>',t.modal=!0,t.autohide=!1),o='<div class="toast-head">'.concat(a).concat(n,'</div><div class="toast-body">').concat(r,"</div>");let u=()=>{E&&(c.doc.body.removeEventListener("keyup",p),E.removeEventListener("keyup",p),E.removeEventListener("touchend",p),E.removeEventListener("click",p),E.remove())},h=w=>{w.removeEventListener("keyup",p),w.removeEventListener("touchend",p),w.removeEventListener("click",p),w.remove(),E&&E.childElementCount===0&&u()},p=w=>{w.stopPropagation(),E&&(console.log("toasterEventHandler",w,E.contains(w.target),b.contains(w.target),b===w.target),u())},m=w=>{w.stopPropagation();let k;if(w.target.classList.contains("toast")?k=w.target:k=w.target.closest(".toast"),!k){c.log(1,"Ui:showDialog","Event target is not a (or in a) toast element, ignoring event")();return}let N=!!k.querySelector("input, textarea, button");if(console.log("toastEventHandler",N,w,k.contains(w.target),k===w.target),N){if(w.key!=="Escape")return;h(k)}h(k)},b=c.doc.createElement("div");if(b.title="Click or Esc to clear this notifcation",b.setAttribute("class","toast ".concat(e)),b.setAttribute("role",e==="alert"?"alertdialog":"dialog"),b.dataset.modal=t.modal,b.dataset.autohide=t.autohide,b.dataset.autoHideDelay=t.autoHideDelay,b.innerHTML=o,t.appendToast===!0){let w=Array.from(c.doc.body.querySelectorAll(".toast")).pop();w?w.insertAdjacentElement("afterend",b):c.doc.body.insertBefore(b,c.doc.body.firstChild)}else c.doc.body.insertBefore(b,c.doc.body.firstChild);b.addEventListener("keyup",m),b.addEventListener("click",m),b.addEventListener("touchend",m),t.autohide===!0&&setInterval(()=>{h(b)},t.autoHideDelay);let E;return t.modal===!0&&(E=c.doc.getElementById("toaster"),E===null&&(E=c.doc.createElement("div"),E.id="toaster",E.title="Click, touch, or ESC to clear notifcations",E.setAttribute("class","toaster"),E.setAttribute("arial-label","Toast message"),E.addEventListener("click",p),E.addEventListener("touchend",p),c.doc.body.addEventListener("keyup",p),c.doc.body.insertAdjacentElement("afterbegin",E))),b}ui(e){let t={};e._ui?t=e:t._ui=e,this._uiManager(t)}uiGet(e,t=null){let i=c.doc.querySelectorAll(e),r=[];return i.forEach(n=>{if(t){t==="classes"&&(t="class");let o=n.getAttribute(t);if(o==null)try{o=n[t]}catch{}if(o==null)t.toLowerCase()==="value"?r.push(n.innerText):r.push("Property '".concat(t,"' not found"));else{let a={},u=o.constructor.name.toLowerCase();if(u==="namednodemap")for(let h of o)a[h.name]=o[h.name].value;else if(!u.includes("map"))a[t]=o;else{let h={};for(let p in o)h[p]=o[p]}a.class&&(a.classes=Array.from(n.classList)),r.push(a)}}else r.push(this.nodeGet(n,e))}),r}uiEnhanceElement(e,t){this._uiComposeComponent(e,t)}createTable(e=[],t={parent:"body"}){if(!t.parent)throw new Error("[ui.js:createTable] opts.parent must be provided");this.buildHtmlTable(e,t)}buildHtmlTable(e,t={}){let i,r=Object.prototype.toString.apply(e);if(r==="[object Array]"||r==="[object Object]")i=Object.keys(e),e=Object.values(e);else{let p=c.doc.createElement("p");return p.textContent="Input data is not an array or an object, cannot create a table.",p}i.length>1e3&&c.log(1,"Uib:buildHtmlTable","Warning, data is ".concat(i.length," rows. Anything over 1,000 can get very slow to complete."))();let n=c.doc.createElement("table"),o=c.doc.createElement("thead"),a=c.doc.createElement("tr");if(!t.cols){if(e.length<1)throw new Error("[ui.js:buildHtmlTable] When no opts.cols is provided, data must contain at least 1 row");let p=Object.prototype.toString.apply(e[0])!=="[object Array]";a.dataset.colReference="",t.cols=[],Object.keys(e[0]).forEach((m,b)=>{t.cols.push({index:b,hasName:p,name:p?m:void 0,key:m!=null?m:b,title:m})})}n.cols=t.cols,t.cols.forEach(p=>{let m=c.doc.createElement("th");m.textContent=p.title,p.hasName===!0&&(m.dataset.colName=name),a.appendChild(m)}),o.appendChild(a),n.appendChild(o);let u=c.doc.createElement("tbody");n.appendChild(u);let h={allowHTML:!0,cols:t.cols};if(e.forEach((p,m)=>{isNaN(Number(i[m]))?h.rowId=i[m]:h.rowId=void 0,this.tblAddRow(n,p,h)}),t.parent){let p;typeof t.parent=="string"?p=c.doc.querySelector(t.parent):p=t.parent;try{p.appendChild(n)}catch(m){throw new Error("[ui.js:buildHtmlTable] Could not add table to parent. ".concat(m.message))}return}return n}tblAddRow(e,t={},i={}){let r=Object.prototype.toString.apply(e);if(Object.prototype.toString.apply(i)!=="[object Object]")throw new Error("[tblAddDataRow] options must be an object");let n=Object.prototype.toString.apply(t);if(n!=="[object Object]"&&n!=="[object Array]")throw new Error("[tblAddDataRow] rowData MUST be an object or an array containing column/cell data for each column");let o;if(r==="[object HTMLTableElement]")o=e;else if(o=c.doc.querySelector(e),!o)throw new Error('[tblAddDataRow] Table with CSS Selector "'.concat(e,'" not found'));i.body||(i.body=0),"allowHTML"in i||(i.allowHTML=!1);let a=o.getElementsByTagName("tbody")[i.body];if(!a)throw new Error("[tblAddDataRow] Table must have a tbody tag, tbody section ".concat(i.body," does not exist"));i.cols||(i.cols=this.tblGetColMeta(o));let u=i.cols,h=c.doc.createElement("tr");i.rowId&&(h.id=i.rowId);let p=[];for(let m of u){let b=c.doc.createElement("td");b.colMeta=m,m.hasName&&(b.dataset.colName=m.name),p.push(b)}if(Object.keys(t).forEach((m,b,E)=>{let w=p.find(N=>{var at;return((at=N==null?void 0:N.colMeta)==null?void 0:at.name)===m}),k;if(w)k=t[m];else{let N=Number(m);isNaN(N)&&(N=b),N<=p.length-1&&(w=p[N],k=Object.values(t)[N])}w&&(i.allowHTML?w.innerHTML=this.sanitiseHTML(k):w.textContent=k)}),h.append(...p),"afterRow"in i){let m=a.rows[i.afterRow];if(m)return m.after(h)}else if("beforeRow"in i){let m=a.rows[i.beforeRow];if(m)return m.before(h)}else if("replaceRow"in i){let m=a.rows[i.replaceRow];if(m)return m.replaceWith(h)}return a.appendChild(h)}tblAddListener(e,t={},i={}){let r=c.doc.querySelector(e);if(!r)throw new Error('Table with CSS Selector "'.concat(e,'" not found'));if(typeof i!="object")throw new Error('The "out" argument MUST be an object');t.eventScope||(t.eventScope="row"),t.returnType||(t.returnType="text"),t.eventType||(t.eventType="click"),t.pad||(t.pad=3),t.logLevel||(t.logLevel=2),"send"in t||(t.send=!0),r.querySelector("tbody").addEventListener(t.eventType,n=>{Object.keys(i).forEach(u=>delete i[u]);let o=n.target.closest("tr"),a=n.target.closest("td");if(o){i.clickType=t.eventScope,i.eventType=t.eventType;let u=i.rowIndex=o.rowIndex,h=i.cellIndex=a.cellIndex+1;if(o.id&&(i.rowId=o.id),t.eventScope==="row")o.querySelectorAll("td").forEach(p=>{let m=this.tblGetCellName(p,t.pad);i[m]=t.returnType==="text"?p.textContent.trim():p.innerHTML});else{let p=this.tblGetCellName(a,t.pad);i[p]=t.returnType==="text"?a.textContent.trim():a.innerHTML}c.log(t.logLevel,"Ui:tblAddClickListener","".concat(t.eventScope," ").concat(t.eventType," on row=").concat(u,", col=").concat(h,", data: "),i)(),t.send===!0&&c.win.uibuilder&&c.win.uibuilder.send({topic:"".concat(e," ").concat(t.eventScope," ").concat(t.eventType),payload:i})}})}tblFindColMeta(e,t,i){if(!t&&!i)throw new Error("[tblFindColMeta] Either the column metadata array or the HTML table element must be provided");!t&&i&&(t=this.tblGetColMeta(i));let r;if(t[e])r=t[e];else{let n=t.find(o=>o.name===e||o.index===Number(e));n&&(r=n)}return r}tblGetCellName(e,t=3){var i;return(i=e.getAttribute("data-col-name"))!=null?i:"C".concat(String(e.cellIndex+1).padStart(t,"0"))}tblGetColMeta(e,t={}){var o,a,u;if(t.pad||(t.pad=3),e.cols)return e.cols;let i=(o=e.querySelector("tr[data-col-reference]"))==null?void 0:o.children;if(i||(i=(a=e.querySelector("thead>tr:first-of-type"))==null?void 0:a.children),i||(i=(u=e.querySelector("tr:first-of-type"))==null?void 0:u.children),!i)return c.log(1,"Ui:tblGetColMeta","No columns found in table")(),[];let r=[],n;for(n of i){let h=!!n.dataset.colName,p=n.dataset.colName,m=n.cellIndex+1,b=h?p:"C".concat(String(n.cellIndex+1).padStart(t.pad,"0"));r.push({index:m,hasName:h,name:p,key:b,title:n.textContent})}return e.cols=r,r}tblRemoveRow(e,t,i={}){let r=Object.prototype.toString.apply(e);if(Object.prototype.toString.apply(i)!=="[object Object]")throw new Error("[tblRemoveRow] options must be an object");let n;if(r==="[object HTMLTableElement]")n=e;else if(n=c.doc.querySelector(e),!n)throw new Error('[tblRemoveRow] Table with CSS Selector "'.concat(e,'" not found'));i.body||(i.body=0);let o=n.getElementsByTagName("tbody")[i.body];if(!o)throw new Error("[tblAddDataRow] Table must have a tbody tag, tbody section ".concat(i.body," does not exist"));o.deleteRow(t)}},d(c,"win"),d(c,"doc"),d(c,"log"),d(c,"mdOpts"),d(c,"md"),c),dt=ri;var A=Object.create(null);A.open="0";A.close="1";A.ping="2";A.pong="3";A.message="4";A.upgrade="5";A.noop="6";var be=Object.create(null);Object.keys(A).forEach(s=>{be[A[s]]=s});var ye={type:"error",data:"parser error"};var mt=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",bt=typeof ArrayBuffer=="function",yt=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,ge=({type:s,data:e},t,i)=>mt&&e instanceof Blob?t?i(e):ft(e,i):bt&&(e instanceof ArrayBuffer||yt(e))?t?i(e):ft(new Blob([e]),i):i(A[s]+(e||"")),ft=(s,e)=>{let t=new FileReader;return t.onload=function(){let i=t.result.split(",")[1];e("b"+(i||""))},t.readAsDataURL(s)};function pt(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}var Fe;function gt(s,e){if(mt&&s.data instanceof Blob)return s.data.arrayBuffer().then(pt).then(e);if(bt&&(s.data instanceof ArrayBuffer||yt(s.data)))return e(pt(s.data));ge(s,!1,t=>{Fe||(Fe=new TextEncoder),e(Fe.encode(t))})}var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",we=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<wt.length;s++)we[wt.charCodeAt(s)]=s;var vt=s=>{let e=s.length*.75,t=s.length,i,r=0,n,o,a,u;s[s.length-1]==="="&&(e--,s[s.length-2]==="="&&e--);let h=new ArrayBuffer(e),p=new Uint8Array(h);for(i=0;i<t;i+=4)n=we[s.charCodeAt(i)],o=we[s.charCodeAt(i+1)],a=we[s.charCodeAt(i+2)],u=we[s.charCodeAt(i+3)],p[r++]=n<<2|o>>4,p[r++]=(o&15)<<4|a>>2,p[r++]=(a&3)<<6|u&63;return h};var si=typeof ArrayBuffer=="function",ve=(s,e)=>{if(typeof s!="string")return{type:"message",data:Et(s,e)};let t=s.charAt(0);return t==="b"?{type:"message",data:ni(s.substring(1),e)}:be[t]?s.length>1?{type:be[t],data:s.substring(1)}:{type:be[t]}:ye},ni=(s,e)=>{if(si){let t=vt(s);return Et(t,e)}else return{base64:!0,data:s}},Et=(s,e)=>{switch(e){case"blob":return s instanceof Blob?s:new Blob([s]);case"arraybuffer":default:return s instanceof ArrayBuffer?s:s.buffer}};var _t="",kt=(s,e)=>{let t=s.length,i=new Array(t),r=0;s.forEach((n,o)=>{ge(n,!1,a=>{i[o]=a,++r===t&&e(i.join(_t))})})},Ct=(s,e)=>{let t=s.split(_t),i=[];for(let r=0;r<t.length;r++){let n=ve(t[r],e);if(i.push(n),n.type==="error")break}return i};function St(){return new TransformStream({transform(s,e){gt(s,t=>{let i=t.length,r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);let n=new DataView(r.buffer);n.setUint8(0,126),n.setUint16(1,i)}else{r=new Uint8Array(9);let n=new DataView(r.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(i))}s.data&&typeof s.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}var Ve;function Ue(s){return s.reduce((e,t)=>e+t.length,0)}function Me(s,e){if(s[0].length===e)return s.shift();let t=new Uint8Array(e),i=0;for(let r=0;r<e;r++)t[r]=s[0][i++],i===s[0].length&&(s.shift(),i=0);return s.length&&i<s[0].length&&(s[0]=s[0].slice(i)),t}function xt(s,e){Ve||(Ve=new TextDecoder);let t=[],i=0,r=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(i===0){if(Ue(t)<1)break;let u=Me(t,1);n=(u[0]&128)===128,r=u[0]&127,r<126?i=3:r===126?i=1:i=2}else if(i===1){if(Ue(t)<2)break;let u=Me(t,2);r=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),i=3}else if(i===2){if(Ue(t)<8)break;let u=Me(t,8),h=new DataView(u.buffer,u.byteOffset,u.length),p=h.getUint32(0);if(p>Math.pow(2,21)-1){a.enqueue(ye);break}r=p*Math.pow(2,32)+h.getUint32(4),i=3}else{if(Ue(t)<r)break;let u=Me(t,r);a.enqueue(ve(n?u:Ve.decode(u),e)),i=0}if(r===0||r>s){a.enqueue(ye);break}}}})}var We=4;function _(s){if(s)return oi(s)}function oi(s){for(var e in _.prototype)s[e]=_.prototype[e];return s}_.prototype.on=_.prototype.addEventListener=function(s,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(e),this};_.prototype.once=function(s,e){function t(){this.off(s,t),e.apply(this,arguments)}return t.fn=e,this.on(s,t),this};_.prototype.off=_.prototype.removeListener=_.prototype.removeAllListeners=_.prototype.removeEventListener=function(s,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+s];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var i,r=0;r<t.length;r++)if(i=t[r],i===e||i.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+s],this};_.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+s],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,r=t.length;i<r;++i)t[i].apply(this,e)}return this};_.prototype.emitReserved=_.prototype.emit;_.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]};_.prototype.hasListeners=function(s){return!!this.listeners(s).length};var U=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),x=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Tt="arraybuffer";function Ie(s,...e){return e.reduce((t,i)=>(s.hasOwnProperty(i)&&(t[i]=s[i]),t),{})}var ai=x.setTimeout,ci=x.clearTimeout;function M(s,e){e.useNativeTimers?(s.setTimeoutFn=ai.bind(x),s.clearTimeoutFn=ci.bind(x)):(s.setTimeoutFn=x.setTimeout.bind(x),s.clearTimeoutFn=x.clearTimeout.bind(x))}var li=1.33;function Ot(s){return typeof s=="string"?ui(s):Math.ceil((s.byteLength||s.size)*li)}function ui(s){let e=0,t=0;for(let i=0,r=s.length;i<r;i++)e=s.charCodeAt(i),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(i++,t+=4);return t}function De(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Nt(s){let e="";for(let t in s)s.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(s[t]));return e}function At(s){let e={},t=s.split("&");for(let i=0,r=t.length;i<r;i++){let n=t[i].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var Be=class extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}},I=class extends _{constructor(e){super(),this.writable=!1,M(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,i){return super.emitReserved("error",new Be(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=ve(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Nt(e);return t.length?"?"+t:""}};var Ee=class extends I{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||t()})),this.writable||(i++,this.once("drain",function(){--i||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};Ct(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,kt(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=De()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};var Rt=!1;try{Rt=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var $t=Rt;function hi(){}var ze=class extends Ee{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",i=location.port;i||(i=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,t){let i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(r,n)=>{this.onError("xhr post error",r,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,i)=>{this.onError("xhr poll error",t,i)}),this.pollXhr=e}},P=class s extends _{constructor(e,t,i){super(),this.createRequest=e,M(this,i),this._opts=i,this._method=i.method||"GET",this._uri=t,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var e;let t=Ie(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let i=this._xhr=this.createRequest(t);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&i.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var r;i.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=s.requestsCount++,s.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=hi,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete s.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};P.requestsCount=0;P.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Lt);else if(typeof addEventListener=="function"){let s="onpagehide"in x?"pagehide":"unload";addEventListener(s,Lt,!1)}}function Lt(){for(let s in P.requests)P.requests.hasOwnProperty(s)&&P.requests[s].abort()}var di=function(){let s=Ut({xdomain:!1});return s&&s.responseType!==null}(),H=class extends ze{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=di&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new P(Ut,this.uri(),e)}};function Ut(s){let e=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||$t))return new XMLHttpRequest}catch{}if(!e)try{return new x[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Mt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ke=class extends I{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,i=Mt?{}:Ie(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,i)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],r=t===e.length-1;ge(i,this.supportsBinary,n=>{try{this.doWrite(i,n)}catch{}r&&U(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=De()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Ge=x.WebSocket||x.MozWebSocket,q=class extends Ke{createSocket(e,t,i){return Mt?new Ge(e,t,i):t?new Ge(e,t):new Ge(e)}doWrite(e,t){this.ws.send(t)}};var te=class extends I{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=xt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),r=St();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let n=()=>{i.read().then(({done:a,value:u})=>{a||(this.onPacket(u),n())}).catch(a=>{})};n();let o={type:"open"};this.query.sid&&(o.data='{"sid":"'.concat(this.query.sid,'"}')),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],r=t===e.length-1;this._writer.write(i).then(()=>{r&&U(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};var Je={websocket:q,webtransport:te,polling:H};var fi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,pi=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ie(s){if(s.length>8e3)throw"URI too long";let e=s,t=s.indexOf("["),i=s.indexOf("]");t!=-1&&i!=-1&&(s=s.substring(0,t)+s.substring(t,i).replace(/:/g,";")+s.substring(i,s.length));let r=fi.exec(s||""),n={},o=14;for(;o--;)n[pi[o]]=r[o]||"";return t!=-1&&i!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=mi(n,n.path),n.queryKey=bi(n,n.query),n}function mi(s,e){let t=/\/{2,9}/g,i=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function bi(s,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,r,n){r&&(t[r]=n)}),t}var Ye=typeof addEventListener=="function"&&typeof removeEventListener=="function",Pe=[];Ye&&addEventListener("offline",()=>{Pe.forEach(s=>s())},!1);var G=class s extends _{constructor(e,t){if(super(),this.binaryType=Tt,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){let i=ie(e);t.hostname=i.host,t.secure=i.protocol==="https"||i.protocol==="wss",t.port=i.port,i.query&&(t.query=i.query)}else t.host&&(t.hostname=ie(t.host).host);M(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(i=>{let r=i.prototype.name;this.transports.push(r),this._transportsByName[r]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=At(this.opts.query)),Ye&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Pe.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=We,t.transport=e,this.id&&(t.sid=this.id);let i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let e=this.opts.rememberUpgrade&&s.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",s.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i<this.writeBuffer.length;i++){let r=this.writeBuffer[i].data;if(r&&(t+=Ot(r)),i>0&&t>this._maxPayload)return this.writeBuffer.slice(0,i);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,U(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,i){return this._sendPacket("message",e,t,i),this}send(e,t,i){return this._sendPacket("message",e,t,i),this}_sendPacket(e,t,i,r){if(typeof t=="function"&&(r=t,t=void 0),typeof i=="function"&&(r=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let n={type:e,data:t,options:i};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),r&&this.once("flush",r),this.flush()}close(){let e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(s.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ye&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let i=Pe.indexOf(this._offlineEventListener);i!==-1&&Pe.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}};G.protocol=We;var He=class extends G{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),i=!1;G.priorWebsocketSuccess=!1;let r=()=>{i||(t.send([{type:"ping",data:"probe"}]),t.once("packet",m=>{if(!i)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;G.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(p(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let b=new Error("probe error");b.transport=t.name,this.emitReserved("upgradeError",b)}}))};function n(){i||(i=!0,p(),t.close(),t=null)}let o=m=>{let b=new Error("probe error: "+m);b.transport=t.name,n(),this.emitReserved("upgradeError",b)};function a(){o("transport closed")}function u(){o("socket closed")}function h(m){t&&m.name!==t.name&&n()}let p=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",a),this.off("close",u),this.off("upgrading",h)};t.once("open",r),t.once("error",o),t.once("close",a),this.once("close",u),this.once("upgrading",h),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}},re=class extends He{constructor(e,t={}){let i=typeof e=="object"?e:t;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(r=>Je[r]).filter(r=>!!r)),super(e,i)}};var $r=re.protocol;function It(s,e="",t){let i=s;t=t||typeof location<"u"&&location,s==null&&(s=t.protocol+"//"+t.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=t.protocol+s:s=t.host+s),/^(https?|wss?):\/\//.test(s)||(typeof t<"u"?s=t.protocol+"//"+s:s="https://"+s),i=ie(s)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";let n=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+e,i.href=i.protocol+"://"+n+(t&&t.port===i.port?"":":"+i.port),i}var it={};ti(it,{Decoder:()=>et,Encoder:()=>Ze,PacketType:()=>g,protocol:()=>qt});var gi=typeof ArrayBuffer=="function",wi=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Dt=Object.prototype.toString,vi=typeof Blob=="function"||typeof Blob<"u"&&Dt.call(Blob)==="[object BlobConstructor]",Ei=typeof File=="function"||typeof File<"u"&&Dt.call(File)==="[object FileConstructor]";function ke(s){return gi&&(s instanceof ArrayBuffer||wi(s))||vi&&s instanceof Blob||Ei&&s instanceof File}function _e(s,e){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let t=0,i=s.length;t<i;t++)if(_e(s[t]))return!0;return!1}if(ke(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return _e(s.toJSON(),!0);for(let t in s)if(Object.prototype.hasOwnProperty.call(s,t)&&_e(s[t]))return!0;return!1}function Bt(s){let e=[],t=s.data,i=s;return i.data=Xe(t,e),i.attachments=e.length,{packet:i,buffers:e}}function Xe(s,e){if(!s)return s;if(ke(s)){let t={_placeholder:!0,num:e.length};return e.push(s),t}else if(Array.isArray(s)){let t=new Array(s.length);for(let i=0;i<s.length;i++)t[i]=Xe(s[i],e);return t}else if(typeof s=="object"&&!(s instanceof Date)){let t={};for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=Xe(s[i],e));return t}return s}function Pt(s,e){return s.data=Qe(s.data,e),delete s.attachments,s}function Qe(s,e){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<e.length)return e[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let t=0;t<s.length;t++)s[t]=Qe(s[t],e);else if(typeof s=="object")for(let t in s)Object.prototype.hasOwnProperty.call(s,t)&&(s[t]=Qe(s[t],e));return s}var _i=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],qt=5,g;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(g||(g={}));var Ze=class{constructor(e){this.replacer=e}encode(e){return(e.type===g.EVENT||e.type===g.ACK)&&_e(e)?this.encodeAsBinary({type:e.type===g.EVENT?g.BINARY_EVENT:g.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===g.BINARY_EVENT||e.type===g.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Bt(e),i=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(i),r}};function Ht(s){return Object.prototype.toString.call(s)==="[object Object]"}var et=class s extends _{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let i=t.type===g.BINARY_EVENT;i||t.type===g.BINARY_ACK?(t.type=i?g.EVENT:g.ACK,this.reconstructor=new tt(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ke(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,i={type:Number(e.charAt(0))};if(g[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===g.BINARY_EVENT||i.type===g.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");i.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););i.nsp=e.substring(n,t)}else i.nsp="/";let r=e.charAt(t+1);if(r!==""&&Number(r)==r){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}i.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(s.isPayloadValid(i.type,n))i.data=n;else throw new Error("invalid payload")}return i}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case g.CONNECT:return Ht(t);case g.DISCONNECT:return t===void 0;case g.CONNECT_ERROR:return typeof t=="string"||Ht(t);case g.EVENT:case g.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&_i.indexOf(t[0])===-1);case g.ACK:case g.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},tt=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=Pt(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function O(s,e,t){return s.on(e,t),function(){s.off(e,t)}}var ki=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),se=class extends _{constructor(e,t,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[O(e,"open",this.onopen.bind(this)),O(e,"packet",this.onpacket.bind(this)),O(e,"error",this.onerror.bind(this)),O(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var i,r,n;if(ki.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let o={type:g.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let p=this.ids++,m=t.pop();this._registerAckCallback(p,m),o.id=p}let a=(r=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||r===void 0?void 0:r.writable,u=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!a||(u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var i;let r=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(n),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((i,r)=>{let n=(o,a)=>o?r(o):i(a);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...n)=>i!==this._queue[0]?void 0:(r!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...n)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:g.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(i=>String(i.id)===e)){let i=this.acks[e];delete this.acks[e],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case g.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case g.EVENT:case g.BINARY_EVENT:this.onevent(e);break;case g.ACK:case g.BINARY_ACK:this.onack(e);break;case g.DISCONNECT:this.ondisconnect();break;case g.CONNECT_ERROR:this.destroy();let i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let i of t)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,i=!1;return function(...r){i||(i=!0,t.packet({type:g.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:g.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let i of t)i.apply(this,e.data)}}};function K(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}K.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*s);s=(Math.floor(e*10)&1)==0?s-t:s+t}return Math.min(s,this.max)|0};K.prototype.reset=function(){this.attempts=0};K.prototype.setMin=function(s){this.ms=s};K.prototype.setMax=function(s){this.max=s};K.prototype.setJitter=function(s){this.jitter=s};var ne=class extends _{constructor(e,t){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,M(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((i=t.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new K({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let r=t.parser||it;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new re(this.uri,this.opts);let t=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;let r=O(t,"open",function(){i.onopen(),e&&e()}),n=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=O(t,"error",n);if(this._timeout!==!1){let a=this._timeout,u=this.setTimeoutFn(()=>{r(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(O(e,"ping",this.onping.bind(this)),O(e,"data",this.ondata.bind(this)),O(e,"error",this.onerror.bind(this)),O(e,"close",this.onclose.bind(this)),O(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){U(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new se(this,e,t),this.nsps[e]=i),i}_destroy(e){let t=Object.keys(this.nsps);for(let i of t)if(this.nsps[i].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let i=0;i<t.length;i++)this.engine.write(t[i],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let i=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Ce={};function J(s,e){typeof s=="object"&&(e=s,s=void 0),e=e||{};let t=It(s,e.path||"/socket.io"),i=t.source,r=t.id,n=t.path,o=Ce[r]&&n in Ce[r].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,u;return a?u=new ne(i,e):(Ce[r]||(Ce[r]=new ne(i,e)),u=Ce[r]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(J,{Manager:ne,Socket:se,io:J,connect:J});var oe=class oe extends HTMLElement{constructor(){super();d(this,"uib",!!window.uibuilder);d(this,"uibuilder",window.uibuilder);d(this,"$");d(this,"$$");d(this,"connected",!1);d(this,"name");d(this,"opts",{})}static get version(){return"".concat(this.componentVersion," (Base: ").concat(this.baseVersion,")")}async doInheritStyles(){if(!this.hasAttribute("inherit-style"))return;let t=this.getAttribute("inherit-style");t||(t="./index.css");let i=document.createElement("link");i.setAttribute("type","text/css"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",t),this.shadowRoot.appendChild(i),console.info("[".concat(this.localName,'] Inherit-style requested. Loading: "').concat(t,'"'))}config(t){return t&&(this.opts=oe.deepAssign(this.opts,t)),this.opts}static deepAssign(t,...i){for(let r of i)for(let n in r){let o=r[n],a=t[n];if(Object(o)==o&&Object(a)===a){t[n]=oe.deepAssign(a,o);continue}t[n]=r[n]}return t}ensureId(){this.uib=!!window.uibuilder,this.id||(this.id="".concat(this.localName,"-").concat(++this.constructor._iCount))}createShadowSelectors(){var t,i;this.$=(t=this.shadowRoot)==null?void 0:t.querySelector.bind(this.shadowRoot),this.$$=(i=this.shadowRoot)==null?void 0:i.querySelectorAll.bind(this.shadowRoot)}_uibMsgHandler(t){}_event(t,i){this.dispatchEvent(new CustomEvent("".concat(this.localName,":").concat(t),{bubbles:!0,composed:!0,detail:{id:this.id,name:this.name,data:i}}))}_construct(t,i){i||(i={mode:"open",delegatesFocus:!0}),this.attachShadow(i).append(t),this.createShadowSelectors()}_connect(){this.ensureId(),this.doInheritStyles()}_disconnect(){document.removeEventListener("uibuilder:msg:_ui:update:".concat(this.id),this._uibMsgHandler),this._event("disconnected")}_ready(){this.connected=!0,this._event("connected"),this._event("ready")}};d(oe,"baseVersion","2025-01-09"),d(oe,"_iCount",0);var rt=oe,ae=rt;var Y,j,ce,$,Se=class extends ae{constructor(){super();v(this,Y);d(this,"value");v(this,j);v(this,ce);v(this,$);d(this,"undef",!1);d(this,"report",!1);d(this,"type","plain");d(this,"types",["plain","html","markdown","object","json","table","list","array"])}static get observedAttributes(){return["name","filter","id","report","topic","type","undefined","variable"]}set variable(t){if(C(this,Y,t),this.splitVarName,t)try{this.splitVarName=t.split(/[\.\[\]\'\"]/),C(this,Y,t=this.splitVarName.shift())}catch(i){throw new Error("[".concat(this.localName,'] variable attribute: Name split failed on "').concat(t,'". ').concat(i.message))}f(this,j)&&this.uibuilder.cancelChange(t,f(this,j)),t&&C(this,j,this.uibuilder.onChange(t,this._varChange.bind(this)))}get variable(){return f(this,Y)}set topic(t){C(this,ce,t),f(this,$)&&this.uibuilder.cancelTopic(t,f(this,$)),t&&C(this,$,this.uibuilder.onTopic(t,this._topicChange.bind(this)))}get topic(){return f(this,ce)}connectedCallback(){this._connect(),this.variable=this.getAttribute("variable"),this.topic=this.getAttribute("topic"),this._ready()}disconnectedCallback(){f(this,j)&&this.uibuilder.cancelChange(f(this,Y),f(this,j)),f(this,$)&&(this.uibuilder.cancelTopic(f(this,ce),f(this,$)),Object.keys(f(this,$)).forEach(t=>{this.uibuilder.cancelTopic(t,f(this,$)[t])})),this._disconnect()}attributeChangedCallback(t,i,r){if(i!==r){switch(this[t]=r,t){case"undefined":{r===""||["on","true","report"].includes(r.toLowerCase())?this.undef=!0:this.undef=!1;break}case"report":{r===""||["on","true","report"].includes(r.toLowerCase())?this.report=!0:this.report=!1;break}case"type":{r===""||!this.types.includes(r.toLowerCase())?this.type="plain":this.type=r;break}case"filter":{if(this.filter=void 0,this.filterArgs=[],!r)break;this.filter=r,r=r.slice(0,127);let n=r.replace(/\s/g,"").match(/([a-zA-Z_$][a-zA-Z_$0-9.-]+)(\((.*)\))?/);if(!n){console.warn('\u26A0\uFE0F [uib-var] Filter function "'.concat(r,'" invalid. Cannot process.'));break}if(this.filter=n[1],n[3]){try{this.filterArgs=JSON.parse(n[3])}catch{}this.filterArgs=n[3].split(",").map(o=>{if(o=o.trim(),isNaN(o)){let a=o.replace(/^["'`]/,"").replace(/["'`]$/,"");try{a=new Function("return ".concat(a))()}catch{}return a}return Number(o)})}!this.variable&&!this.topic&&this.showVar(!1);break}default:break}this._event("attribChanged",{attribute:t,newVal:r,oldVal:i})}}_varChange(t){let i=!0;if(this.splitVarName.length>0){let r=t,n=[];try{this.splitVarName.forEach(o=>{let a;r[o]===void 0?a=!1:a=!0,n.push(a),r=r[o]}),t=r,i=n.filter(Boolean).length>0}catch{i=!1}}i&&(this.value=t,this.showVar(),this.report===!0&&this.uibuilder.send({topic:this.variable,payload:this.value||void 0,source:this.localName,id:this.id}))}_topicChange(t){this.uibuilder.log("trace",this.localName,"Topic msg received: '".concat(t.topic,"'"),t),this.value=t.payload,this.showVar(),this.report===!0&&this.uibuilder.send({topic:t.topic,payload:this.value||void 0,source:this.localName,id:this.id})}showVar(t=!0){if(this.uibuilder.log("trace",this.localName,"showVar. chkVal: '".concat(t,"'. Value="),this.value),t===!0&&!this.value&&this.undef!==!0)return;let i=t?this.doFilter(this.value):this.doFilter(),r=i;switch(this.type){case"markdown":{this.uib&&(r=this.uibuilder.convertMarkdown(i));break}case"json":case"object":{r='<pre class="syntax-highlight">'.concat(this.uib?this.uibuilder.syntaxHighlight(i):i,"</pre>");break}case"table":{r=this.uibuilder.buildHtmlTable(i).outerHTML;break}case"array":case"list":{Array.isArray(i)||(i=[i]),r="<ul>",i.forEach(n=>{r+="<li>".concat(n,"</li>")}),r+="</ul>";break}case"plain":case"html":default:{let n=typeof i;if(Array.isArray(i)||n==="[object Object]"||n==="object")try{r=JSON.stringify(i)}catch{}break}}this.uib?this.innerHTML=this.uibuilder.sanitiseHTML(r):this.innerHTML=r}doFilter(t){if(this.filter){let i=this.filter.split("."),r=globalThis[i[0]];if(r&&i.length>1&&[i.pop()].forEach(o=>{r=r[o]}),!r&&this.uib===!0&&(r=this.uibuilder[i[0]]),r&&typeof r!="function"&&(r=void 0),r){let n=t===void 0?[...this.filterArgs]:[t,...this.filterArgs];t=Reflect.apply(r,t!=null?t:r,n)}else console.warn('\u26A0\uFE0F [uib-var] Filter function "'.concat(this.filter,'" ').concat(typeof r=="object"?"is an object not a function":"not found"))}return t}};Y=new WeakMap,j=new WeakMap,ce=new WeakMap,$=new WeakMap,d(Se,"componentVersion","2025-01-05");var jt=Se;window.UibVar=Se;var xe=class extends ae{constructor(){super();d(this,"variable","pageMeta");d(this,"value");d(this,"undef",!1);d(this,"report",!1);d(this,"type","created");d(this,"types",["created","updated","crup","both","size","modified","all"]);d(this,"format","");d(this,"formats",["d","dt","t","k","m"]);d(this,"topicMonitors",{});if(this.shadow=this.attachShadow({mode:"open",delegatesFocus:!0}),this.$=this.shadowRoot.querySelector.bind(this.shadowRoot),!this.uibuilder)throw new Error("[uib-meta] uibuilder client library not available");this.value=this.uibuilder.get("pageMeta"),this.value||this.uibuilder.getPageMeta(),this.doWatch()}static get observedAttributes(){return["inherit-style","name","type","format"]}connectedCallback(){this._connect(),this._ready()}disconnectedCallback(){this._disconnect()}attributeChangedCallback(t,i,r){if(i!==r){switch(t){case"type":{r===""||!this.types.includes(r.toLowerCase())?this.type="created":this.type=r;break}case"format":{this.formats.includes(r.toLowerCase())?this[t]=r:this.type="";break}default:{this[t]=r;break}}this._event("attribChanged",{attribute:t,newVal:r,oldVal:i})}}doWatch(){this.varDom(),window.uibuilder.onChange(this.variable,t=>{this.value=t,this.varDom(),this.report===!0&&window.uibuilder.send({topic:this.variable,payload:this.value||void 0})})}varDom(t=!0){if(t===!0&&!this.value&&this.undef!==!0){this.shadow.innerHTML="<slot></slot>";return}let i;switch(this.type.toLowerCase()){case"all":{i="Created: ".concat(this.doFormat(this.value.created,"dt"),", Updated: ").concat(this.doFormat(this.value.modified,"dt")),i+=", Size: ".concat(this.doFormat(this.value.size,"num"),"b");break}case"size":{i="Size: ".concat(this.doFormat(this.value.size,"num"),"b");break}case"modified":case"updated":{i="Updated: ".concat(this.doFormat(this.value.modified,"dt"));break}case"both":case"created-updated":case"crup":{i="Created: ".concat(this.doFormat(this.value.created,"dt"),", Updated: ").concat(this.doFormat(this.value.modified,"dt"));break}case"created":default:{i="Created: ".concat(this.doFormat(this.value.created,"dt"));break}}i!==void 0&&(this.shadow.innerHTML=i)}doFormat(t,i){if(this.format==="")return t;let r;switch(this.format){case"d":{i==="dt"?r=new Date(t).toLocaleDateString():r=t;break}case"t":{i==="dt"?r=new Date(t).toLocaleTimeString():r=t;break}case"dt":{i==="dt"?r=new Date(t).toLocaleString():r=t;break}case"k":{i==="num"?r="".concat(uibuilder.round(t/1024,1)," k"):r=t;break}case"m":{i==="num"?r="".concat(uibuilder.round(t/1048576,2)," M"):r=t;break}default:r=t}return r}};d(xe,"componentVersion","2025-01-06");var Ft=xe;window.UibMeta=xe;var Te=class extends ae{constructor(){super();d(this,"once",!1);if(!this.uibuilder)throw new Error("[apply-template] uibuilder client library not available")}static get observedAttributes(){return["name","template-id","once"]}connectedCallback(){this._connect();let t=this["template-id"],i=this.once;if(!t)throw new Error("[ApplyTemplate] Template id attribute not provided. Template must be identified by an id attribute");let r=document.getElementById(t);if(!r||r.tagName!=="TEMPLATE")throw new Error("[ApplyTemplate] Source must be a <template>. id='".concat(t,"'"));let n=this.innerHTML;this.innerHTML="";let o;if(i===!1?o=document.importNode(r.content,!0):o=document.adoptNode(r.content),this.appendChild(o),n){let a=this.getElementsByTagName("slot");a.length>0&&(a[0].innerHTML=n)}this._ready()}disconnectedCallback(){this._disconnect()}attributeChangedCallback(t,i,r){i!==r&&(this[t]=r,this._event("attribChanged",{attribute:t,newVal:r,oldVal:i}))}};d(Te,"componentVersion","2025-01-05");var Vt=Te;window.ApplyTemplate=Te;var le=class{constructor(e){this.target=typeof e=="object"&&e!==null?e:{value:e},this.changeListeners=new Map,this.listenerIdCounter=0}_isReactive(e){return e&&e.__v_isReactive===!0}_triggerListeners(e,t,i,r){this.changeListeners.forEach(n=>{try{n(t,i,e,r)}catch(o){console.warn('[uibuilder:reactive] Error in onChange listener for "'.concat(e,'":'),o)}})}_createReactiveObject(e,t=""){return!e||typeof e!="object"||this._isReactive(e)?e:Element&&e instanceof Element||typeof e=="function"||e instanceof Date||e instanceof RegExp?(console.warn("[uibuilder:reactive] Can not proxy DOM elements, functions or other special objects"),e):new Proxy(e,{get:(r,n,o)=>{if(n==="__v_isReactive")return!0;if(n==="onChange")return u=>{if(typeof u!="function")throw new Error("[uibuilder:reactive] onChange callback must be a function");let h=++this.listenerIdCounter;return this.changeListeners.set(h,u),{id:h,cancel:()=>{this.changeListeners.delete(h)}}};if(n==="cancelChange")return u=>{if(!u||typeof u.cancel!="function")return console.warn("[uibuilder:reactive] Invalid listener reference provided to cancelChange"),!1;try{return u.cancel(),!0}catch(h){return console.warn("[uibuilder:reactive] Error cancelling listener:",h),!1}};let a=Reflect.get(r,n,o);if(a&&typeof a=="object"&&!this._isReactive(a)){let u=t?"".concat(t,".").concat(String(n)):String(n);return this._createReactiveObject(a,u)}return a},set:(r,n,o,a)=>{if(n==="__v_isReactive"||n==="onChange"||n==="cancelChange")return!0;let u=r[n],h=Object.prototype.hasOwnProperty.call(r,n),p=Reflect.set(r,n,o,a);if(!h||o!==u){let m=t?"".concat(t,".").concat(String(n)):String(n);this._triggerListeners(m,o,u,a);try{this._dispatchCustomEvent("uibuilder:reactive:propertyChanged",{property:m,value:o,oldValue:u,target:a})}catch(b){console.warn("[uibuilder:reactive] Error dispatching custom event:",b)}}return p},deleteProperty:(r,n)=>{let o=Object.prototype.hasOwnProperty.call(r,n),a=r[n],u=Reflect.deleteProperty(r,n);if(o&&u){let h=t?"".concat(t,".").concat(String(n)):String(n);this._triggerListeners(h,void 0,a,r);try{this._dispatchCustomEvent("uibuilder:reactive:propertyDeleted",{property:h,oldValue:a,target:r})}catch(p){console.warn("[uibuilder:reactive] Error dispatching delete event:",p)}}return u}})}_dispatchCustomEvent(e,t){let i=new CustomEvent(e,{detail:t});document.dispatchEvent(i)}create(){return this._createReactiveObject(this.target)}getListenerCount(){return this.changeListeners.size}clearAllListeners(){this.changeListeners.clear()}};d(le,"version","2025-06-14");function Wt(s){return new le(s).create()}var zt="7.5.0-src",Ci=!/param/.test(function(s){});function l(){let s=Array.from(arguments),e=s.shift(),t;switch(e){case"trace":case 5:{if(l.level<5)break;e=5,t="trace";break}case"debug":case 4:{if(l.level<4)break;e=4,t="debug";break}case"log":case 3:{if(l.level<3)break;e=3,t="log";break}case"info":case"":case 2:{if(l.level<2)break;e=2,t="info";break}case"warn":case 1:{if(l.level<1)break;e=1,t="warn";break}case"error":case"err":case 0:{if(l.level<0)break;e=0,t="error";break}case"print":{if(l.level<0)break;e=0,t="print";break}default:{e=-1;break}}if(t===void 0)return function(){};let i=s.shift();return Function.prototype.bind.call(console[l.LOG_STYLES[t].console],console,"%c".concat(l.LOG_STYLES[t].pre).concat(t,"%c [").concat(i,"]"),"".concat(l.LOG_STYLES.level," ").concat(l.LOG_STYLES[t].css),"".concat(l.LOG_STYLES.head," ").concat(l.LOG_STYLES[t].txtCss),...s)}l.LOG_STYLES={print:{css:"background: grey; color: yellow;",txtCss:"color: grey;",pre:"\u27A1\uFE0F",console:"log"},error:{css:"background: red; color: black;",txtCss:"color: red; ",pre:"\u26D4 ",console:"error"},warn:{css:"background: darkorange; color: black;",txtCss:"color: darkorange; ",pre:"\u26A0 ",console:"warn"},info:{css:"background: aqua; color: black;",txtCss:"color: aqua;",pre:"\u2757 ",console:"info"},log:{css:"background: grey; color: yellow;",txtCss:"color: grey;",pre:"",console:"log"},debug:{css:"background: chartreuse; color: black;",txtCss:"color: chartreuse;",pre:"",console:"debug"},trace:{css:"background: indigo; color: yellow;",txtCss:"color: hotpink;",pre:"",console:"log"},names:["print","error","warn","info","log","debug","trace"],reset:"color: inherit;",head:"font-weight:bold; font-style:italic;",level:"font-weight:bold; border-radius: 3px; padding: 2px 5px; display:inline-block;"};l.default=1;var F,Oe;try{Oe=document.currentScript,F=Oe.getAttribute("logLevel")}catch{}if(F===void 0)try{F=new URL(import.meta.url).searchParams.get("logLevel")}catch{}F!==void 0&&(F=Number(F),isNaN(F)?(console.warn('[Uib:constructor] Cannot set logLevel to "'.concat(Oe==null?void 0:Oe.getAttribute("logLevel"),'". Defaults to 0 (error).')),l.default=0):l.default=F);l.level=l.default;function Gt(s){if(s===void 0)s='<span class="undefined">undefined</span>';else try{s=JSON.stringify(s,void 0,4),s=s.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g,function(e){let t="number";return/^"/.test(e)?/:$/.test(e)?t="key":t="string":/true|false/.test(e)?t="boolean":/null/.test(e)&&(t="null"),'<span class="'.concat(t,'">').concat(e,"</span>")})}catch(e){s="Syntax Highlight ERROR: ".concat(e.message)}return s}var y=new dt(window,l,Gt),T,X,R,L,S,Ne,ue,he,Q,de,qe,Ae,Re,V,$e,st=(T=class{constructor(){d(this,"connectedNum",0);d(this,"_ioChannels",{control:"uiBuilderControl",client:"uiBuilderClient",server:"uiBuilder"});v(this,X);v(this,R,{});v(this,L,{});d(this,"isVue",!1);d(this,"vueVersion");v(this,S,null);v(this,Ne);d(this,"_socket");d(this,"_htmlObserver");v(this,ue,!1);v(this,he,!1);v(this,Q,!1);v(this,de,0);v(this,qe,["elementExists","get","getManagedVarList","getWatchedVars","htmlSend","include","navigate","scrollTo","set","showMsg","showStatus","uiGet","uiWatch","watchUrlHash"]);v(this,Ae,{});v(this,Re,{online:{var:"online",label:"Online?",description:"Is the browser online?"},ioConnected:{var:"ioConnected",label:"Socket.IO connected?",description:"Is Socket.IO connected?"},connectedNum:{var:"connectedNum",label:"# reconnections",description:"How many times has Socket.IO had to reconnect since last page load?"},clientId:{var:"clientId",label:"Client ID",description:"Static client unique id set in Node-RED. Only changes when browser is restarted."},tabId:{var:"tabId",label:"Browser tab ID",description:"Static unique id for the browser's current tab"},cookies:{var:"cookies",label:"Cookies",description:"Cookies set in Node-RED"},httpNodeRoot:{var:"httpNodeRoot",label:"httpNodeRoot",description:"From Node-RED' settings.js, affects URL's. May be wrong for pages in sub-folders"},pageName:{var:"pageName",label:"Page name",description:"Actual name of this page"},ioNamespace:{var:"ioNamespace",label:"SIO namespace",description:"Socket.IO namespace - unique to each uibuilder node instance"},socketError:{var:"socketError",label:"Socket error",description:"If the Socket.IO connection has failed, says why"},msgsSent:{var:"msgsSent",label:"# msgs sent",description:"How many standard messages have been sent to Node-RED?"},msgsReceived:{var:"msgsReceived",label:"# msgs received",description:"How many standard messages have been received from Node-RED?"},msgsSentCtrl:{var:"msgsSentCtrl",label:"# control msgs sent",description:"How many control messages have been sent to Node-RED?"},msgsCtrlReceived:{var:"msgsCtrlReceived",label:"# control msgs received",description:"How many control messages have been received from Node-RED?"},originator:{var:"originator",label:"Node Originator",description:"If the last msg from Node-RED was from a `uib-sender` node, this will be its node id so that messasges can be returned to it"},topic:{var:"topic",label:"Default topic",description:"Optional default topic to be included in outgoing standard messages"},started:{var:"started",label:"Has uibuilder client started?",description:"Whether `uibuilder.start()` ran successfully. This should self-run and should not need to be run manually"},version:{var:"version",label:"uibuilder client version",description:"The version of the loaded uibuilder client library"},serverTimeOffset:{var:"serverTimeOffset",label:"Server time offset (Hrs)",description:"The number of hours difference between the Node-red server and the client"}});v(this,V,{});d(this,"uibAttribs",["uib-topic","data-uib-topic"]);v(this,$e,"[".concat(this.uibAttribs.join("], ["),"]"));d(this,"clientId","");d(this,"cookies",{});d(this,"ctrlMsg",{});d(this,"ioConnected",!1);d(this,"isMinified",Ci);d(this,"isVisible",!1);d(this,"lastNavType","");d(this,"maxHttpBufferSize",1048576);d(this,"msg",{});d(this,"msgsSent",0);d(this,"msgsReceived",0);d(this,"msgsSentCtrl",0);d(this,"msgsCtrlReceived",0);d(this,"online",navigator.onLine);d(this,"sentCtrlMsg",{});d(this,"sentMsg",{});d(this,"serverTimeOffset",null);d(this,"socketError",null);d(this,"tabId","");d(this,"pageName",null);d(this,"purify",!1);d(this,"markdown",!1);d(this,"urlHash",location.hash);d(this,"originator","");d(this,"topic");d(this,"uibrouterinstance");d(this,"uibrouter_CurrentRoute");d(this,"autoSendReady",!0);d(this,"httpNodeRoot","");d(this,"ioNamespace","");d(this,"ioPath","");d(this,"retryFactor",1.5);d(this,"retryMs",2e3);d(this,"storePrefix","uib_");d(this,"started",!1);d(this,"socketOptions",{path:this.ioPath,transports:["polling","websocket"],auth:e=>{e({clientVersion:zt,clientId:this.clientId,pathName:window.location.pathname,urlParams:Object.fromEntries(new URLSearchParams(location.search)),pageName:this.pageName,tabId:this.tabId,lastNavType:this.lastNavType,connectedNum:++this.connectedNum,browserConnectTimestamp:new Date().toISOString()})},transportOptions:{polling:{extraHeaders:{"x-clientid":"".concat(T._meta.displayName,"; ").concat(T._meta.type,"; ").concat(T._meta.version,"; ").concat(this.clientId)}}}});d(this,"$",y.$);d(this,"$$",y.$$);d(this,"$ui",y);d(this,"addClass",y.addClass);d(this,"applyTemplate",y.applyTemplate);d(this,"removeClass",y.removeClass);if(l("trace","Uib:constructor","Starting")(),window.addEventListener("offline",e=>{this.set("online",!1),this.set("ioConnected",!1),l("warn","Browser","DISCONNECTED from network")()}),window.addEventListener("online",e=>{this.set("online",!0),l("warn","Browser","Reconnected to network")(),this._checkConnect()}),document.cookie.split(";").forEach(e=>{let t=e.split("=");this.cookies[t[0].trim()]=t[1]}),this.set("clientId",this.cookies["uibuilder-client-id"]),l("trace","Uib:constructor","Client ID: ",this.clientId)(),this.set("tabId",window.sessionStorage.getItem("tabId")),this.tabId||(this.set("tabId","t".concat(Math.floor(Math.random()*1e6))),window.sessionStorage.setItem("tabId",this.tabId)),document.addEventListener("load",()=>{this.set("isVisible",!0)}),document.addEventListener("visibilitychange",()=>{this.set("isVisible",document.visibilityState==="visible"),this.sendCtrl({uibuilderCtrl:"visibility",isVisible:this.isVisible})}),document.addEventListener("uibuilder:propertyChanged",e=>{f(this,he)&&e.detail.prop in f(this,Re)&&(document.querySelector('td[data-vartype="'.concat(e.detail.prop,'"]')).innerText=JSON.stringify(e.detail.value))}),this.set("ioNamespace",this._getIOnamespace()),"uibuilder-webRoot"in this.cookies)this.set("httpNodeRoot",this.cookies["uibuilder-webRoot"]),l("trace","Uib:constructor",'httpNodeRoot set by cookie to "'.concat(this.httpNodeRoot,'"'))();else{let e=window.location.pathname.split("/").filter(function(t){return t.trim()!==""});e.length>0&&e[e.length-1].endsWith(".html")&&e.pop(),e.pop(),this.set("httpNodeRoot","/".concat(e.join("/"))),l("trace","[Uib:constructor]",'httpNodeRoot set by URL parsing to "'.concat(this.httpNodeRoot,'". NOTE: This may fail for pages in sub-folders.'))()}this.set("ioPath",this.urlJoin(this.httpNodeRoot,T._meta.displayName,"vendor","socket.io")),l("trace","Uib:constructor",'ioPath: "'.concat(this.ioPath,'"'))(),this.set("pageName",window.location.pathname.replace("".concat(this.ioNamespace,"/"),"")),this.pageName.endsWith("/")&&this.set("pageName","".concat(this.pageName,"index.html")),this.pageName===""&&this.set("pageName","index.html");try{let e=this.getStore("_uibAutoloadVars");Object.keys(e).length>0&&Object.keys(e).forEach(t=>{this.set(t,this.getStore(t))})}catch{}this._dispatchCustomEvent("uibuilder:constructorComplete"),l("trace","Uib:constructor","Ending")()}set logLevel(e){l.level=e,console.log("%c\u2757 info%c [logLevel]","".concat(l.LOG_STYLES.level," ").concat(l.LOG_STYLES.info.css),"".concat(l.LOG_STYLES.head," ").concat(l.LOG_STYLES.info.txtCss),"Set to ".concat(e," (").concat(l.LOG_STYLES.names[e],")"))}get logLevel(){return l.level}get meta(){return T._meta}set(e,t,i=!1,r=!1){var o;if(e.startsWith("_")||e.startsWith("#"))return l("warn","Uib:set",'Cannot use set() on protected property "'.concat(e,'"'))(),'Cannot use set() on protected property "'.concat(e,'"');let n=(o=this[e])!=null?o:void 0;return this[e]=t,f(this,Ae)[e]=e,i===!0&&this.setStore(e,t,r),l("trace","Uib:set","prop set - prop: ".concat(e,", val: "),t," store: ".concat(i,", autoload: ").concat(r))(),this._dispatchCustomEvent("uibuilder:propertyChanged",{prop:e,value:t,oldValue:n,store:i,autoload:r}),this._dispatchCustomEvent("uibuilder:propertyChanged:".concat(e),{prop:e,value:t,oldValue:n,store:i,autoload:r}),t}get(e){if(e.startsWith("_")||e.startsWith("#")){l("warn","Uib:get",'Cannot use get() on protected property "'.concat(e,'"'))();return}return e==="version"?T._meta.version:e==="msgsCtrl"?this.msgsCtrlReceived:e==="reconnections"?this.connectedNum:(this[e]===void 0&&l("warn","Uib:get",'get() - property "'.concat(e,'" is undefined'))(),this[e])}setStore(e,t,i=!1){let r={};if(i===!0)try{r=this.getStore("_uibAutoloadVars")||{}}catch{}if(typeof t=="object")try{t=JSON.stringify(t)}catch(n){return l("error","Uib:setStore","Cannot stringify object, not storing. ",n)(),!1}try{if(localStorage.setItem(this.storePrefix+e,t),i){r[e]=e;try{localStorage.setItem(this.storePrefix+"_uibAutoloadVars",JSON.stringify(r))}catch(n){l("error","Uib:setStore","Cannot save autoload list. ",n)()}}return this._dispatchCustomEvent("uibuilder:propertyStored",{prop:e,value:t,autoload:i}),!0}catch(n){return l("error","Uib:setStore","Cannot write to localStorage. ",n)(),!1}}getStore(e){try{return JSON.parse(localStorage.getItem(this.storePrefix+e))}catch{}try{return localStorage.getItem(this.storePrefix+e)}catch{return}}removeStore(e){try{localStorage.removeItem(this.storePrefix+e)}catch{}}getManagedVarList(){return f(this,Ae)}getWatchedVars(){return Object.keys(f(this,R))}_dispatchCustomEvent(e,t){let i=new CustomEvent(e,{detail:t});document.dispatchEvent(i)}onChange(e,t){f(this,R)[e]?f(this,R)[e]._nextRef++:f(this,R)[e]={_nextRef:1};let i=f(this,R)[e]._nextRef,r=f(this,R)[e][i]=function(o){if(e===o.detail.prop){let a=o.detail.value;t.call(a,a)}};return document.addEventListener("uibuilder:propertyChanged",r),i}cancelChange(e,t){document.removeEventListener("uibuilder:propertyChanged",f(this,R)[e][t]),delete f(this,R)[e][t]}onTopic(e,t){f(this,L)[e]?f(this,L)[e]._nextRef++:f(this,L)[e]={_nextRef:1};let i=f(this,L)[e]._nextRef,r=f(this,L)[e][i]=function(o){let a=o.detail;a.topic===e&&t.call(a,a)};return document.addEventListener("uibuilder:stdMsgReceived",r),i}cancelTopic(e,t){document.removeEventListener("uibuilder:stdMsgReceived",f(this,L)[e][t]),delete f(this,L)[e][t]}_checkTimestamp(e){if(Object.prototype.hasOwnProperty.call(e,"serverTimestamp")){let t=new Date(e.serverTimestamp),i=Math.round((new Date-t)/36e5);i!==this.serverTimeOffset&&(l("trace","Uib:checkTimestamp:".concat(this._ioChannels.server," (server)"),"Offset changed to: ".concat(i," from: ").concat(this.serverTimeOffset))(),this.set("serverTimeOffset",i))}}_watchHashChanges(){this.set("urlHash",location.hash),window.addEventListener("hashchange",e=>{this.set("urlHash",location.hash),f(this,Q)===!0&&this.send({topic:"hashChange",payload:location.hash,newHash:this.keepHashFromUrl(e.newURL),oldHash:this.keepHashFromUrl(e.oldURL)})})}arrayIntersect(e,t){return e.filter(i=>t.includes(i))}copyToClipboard(e){let t="";try{t=JSON.stringify(this.get(e))}catch(i){l("error","copyToClipboard",'Could not copy "'.concat(e,'" to clipboard.'),i.message)()}navigator.clipboard.writeText(t)}elementExists(e,t=!0){let i=document.querySelector(e),r=!1;return i!==null&&(r=!0),t===!0&&this.send({payload:r,info:'Element "'.concat(e,'" ').concat(r?"exists":"does not exist")}),r}formatNumber(e,t,i,r){if(isNaN(e))return l("error","formatNumber",'Value must be a number. Value type: "'.concat(typeof e,'"'))(),"NaN";r||(r={}),i||(i=navigator.language?navigator.language:"en-GB"),t&&(r.minimumFractionDigits=t,r.maximumFractionDigits=t);let n;try{n=Number(e).toLocaleString(i,r)}catch(o){return l("error","formatNumber","".concat(o.message,". value=").concat(e,", dp=").concat(t,', intl="').concat(i,'", opts=').concat(JSON.stringify(r)))(),"NaN"}return n}getObjectSize(e){let t;try{let i=JSON.stringify(e);t=new TextEncoder().encode(i).length}catch(i){l("error","uibuilder:getObjectSize","Could not stringify, cannot determine size",e,i)()}return t}hasUibRouter(){return!!this.uibrouterinstance}keepHashFromUrl(e){return e?"#"+e.replace(/^.*#(.*)/,"$1").replace(/\?.*$/,""):""}log(){l(...arguments)()}makeMeAnObject(e,t){t||(t="payload"),typeof t!="string"&&(l("warn","uibuilder:makeMeAnObject","WARNING: property parameter must be a string and not: ".concat(typeof t))(),t="payload");let i={};return e!==null&&e.constructor.name==="Object"?i=e:e!==null&&(i[t]=e),i}navigate(e){return e&&(window.location.href=e),window.location}reactive(e){return Wt(e)}getReactiveClass(){return le}resolveDataSource(e){try{let t=e.split(/[\.\[\]\'\"]/).filter(Boolean),i=window;for(let r of t)i=i==null?void 0:i[r];return i}catch(t){return l("error","uibuilder:resolveDataSource",'Error resolving data source "'.concat(e,"\", returned 'null'. ").concat(t.message))(),null}}round(e,t){let i=Math.pow(10,t||0),r=e*i*(1+Number.EPSILON);return Math.round(r)/i}setOriginator(e=""){this.set("originator",e)}setPing(e=0){let t=new XMLHttpRequest;t.addEventListener("load",()=>{let i=t.getAllResponseHeaders().split("\r\n"),r=Number(new Date)-Number(t.responseURL.split("=")[1]);this.set("ping",{success:t.status===201||t.status===204,status:t.status,headers:i,url:t.responseURL,elapsedTime:r})}),f(this,X)&&(clearInterval(f(this,X)),C(this,X,void 0)),t.open("GET","".concat(this.httpNodeRoot,"/uibuilder/ping?t=").concat(Number(new Date))),t.send(),e>0&&C(this,X,setInterval(()=>{t.open("GET","".concat(this.httpNodeRoot,"/uibuilder/ping?t=").concat(Number(new Date))),t.send()},e))}syntaxHighlight(e){return Gt(e)}truthy(e,t){let i;return["on","On","ON","true","True","TRUE","1",!0,1].includes(e)?i=!0:["off","Off","OFF","false","False","FALSE","0",!1,0].includes(e)?i=!1:i=t,i}urlJoin(){return("/"+Array.prototype.slice.call(arguments).map(function(i){return i.replace(/^\/|\/$/g,"")}).filter(function(i){return i}).join("/")).replace("//","/")}watchUrlHash(e){return C(this,Q,this.truthy(e,f(this,Q)!==!0)),f(this,Q)}elementIsVisible(){return l("error","uib:elementIsVisible","elementIsVisible has been temporarily DEPRECATED as it was not working correctly and a fix is complex")(),this.send({payload:"elementIsVisible has been temporarily DEPRECATED as it was not working correctly and a fix is complex"}),!1}buildHtmlTable(e,t={}){return y.buildHtmlTable(e,t)}createTable(e=[],t={parent:"body"}){y.createTable(e,t)}convertMarkdown(e){return y.convertMarkdown(e)}async include(e,t){await y.include(e,t)}loadScriptSrc(e){y.loadScriptSrc(e)}loadStyleSrc(e){y.loadStyleSrc(e)}loadScriptTxt(e){y.loadScriptTxt(e)}loadStyleTxt(e){y.loadStyleTxt(e)}loadui(e){y.loadui(e)}replaceSlot(e,t){y.replaceSlot(e,t)}replaceSlotMarkdown(e,t){y.replaceSlotMarkdown(e,t)}sanitiseHTML(e){return y.sanitiseHTML(e)}tblAddListener(e,t={},i={}){y.tblAddListener(e,t,i)}tblAddRow(e,t={},i={}){return y.tblAddRow(e,t,i)}tblRemoveRow(e,t,i={}){y.tblRemoveRow(e,t,i)}showDialog(e,t,i){y.showDialog(e,t,i)}ui(e){y.ui(e)}uiGet(e,t=null){return y.uiGet(e,t)}uiEnhanceElement(e,t){y.uiEnhanceElement(e,t)}async _uibAttribObserver(e){e.forEach(async t=>{l("trace","uibuilder:_uibAttribObserver","Mutations ",t)(),t.attributeName&&(t.attributeName.startsWith("uib")||t.attributeName.startsWith("data-uib"))?this._uibAttrScanOne(t.target):t.addedNodes.length>0&&t.addedNodes.forEach(async i=>{let r=[];try{r=[...i.attributes]}catch{}this.arrayIntersect(this.uibAttribs,r).forEach(async a=>{this._uibAttrScanOne(a)});let o=[];i.querySelectorAll&&(o=i.querySelectorAll(f(this,$e))),o.forEach(async a=>{this._uibAttrScanOne(a)})})})}_processUibTopic(e,t){this.onTopic(t,i=>{if(l("trace","uibuilder:_uibAttrScanOne",'Msg with topic "'.concat(t,'" received. msg content: '),i)(),i._uib_processed_by="_uibAttrScanOne",Object.prototype.hasOwnProperty.call(i,"attributes"))try{for(let[o,a]of Object.entries(i.attributes))e.setAttribute(o,a)}catch{l(0,"uibuilder:attribute-processing","Failed to set attributes. Ensure that msg.attributes is an object containing key/value pairs with each key a valid attribute name. Note that attribute values have to be a string.")()}if(Object.prototype.hasOwnProperty.call(i,"dataset")){console.log("uibuilder:dataset-processing","Processing dataset for element",e,i.dataset);try{for(let[o,a]of Object.entries(i.dataset))e.dataset[o]=a}catch{l("error","uibuilder:dataset-processing","Failed to set dataset. Ensure that msg.dataset is an object containing key/value pairs with each key a valid dataset name. Note that dataset values have to be a string.")()}}let r=Object.prototype.hasOwnProperty.call(i,"checked"),n=Object.prototype.hasOwnProperty.call(i,"value");(n||r)&&(e.type&&(e.type==="checkbox"||e.type==="radio")?r?e.checked=this.truthy(i.checked,!1):n&&(e.checked=this.truthy(i.value,!1)):n?e.value=i.value:r&&(e.value=this.truthy(i.checked,!1))),Object.prototype.hasOwnProperty.call(i,"payload")&&this.replaceSlot(e,i.payload)})}async _uibAttrScanOne(e){if(l("trace","uibuilder:_uibAttrScanOne","Setting up auto-processor for: ",e)(),!e||!e.attributes)return;let t=[...e.attributes].filter(i=>i.name.startsWith("uib-")||i.name.startsWith("data-uib-")||i.name.startsWith(":"));t.length!==0&&(t=[...new Set(t)],t.forEach(i=>{var r;if((i==null?void 0:i.name)==="uib-topic"||(i==null?void 0:i.name)==="data-uib-topic")this._processUibTopic(e,i.value);else if(i!=null&&i.name.startsWith("uib-bind:")||i!=null&&i.name.startsWith("data-uib-bind:")||i!=null&&i.name.startsWith(":")){let n=i.name.replace(/^(uib-bind:|data-uib-bind:|:)/,""),o=i.value;try{o=new Function("return (".concat(i.value,")"))(),l("print","uibuilder:_uibAttrScanOne","SUCCESS 1 uib-bind attribute:",n,"with value:",o)()}catch{l("print","uibuilder:_uibAttrScanOne","\u{1F7E5}Error 1 uib-bind attribute:",n,"with value:",o)();try{console.log(globalThis),o=(r=globalThis[i.value])!=null?r:i.value,l("print","uibuilder:_uibAttrScanOne","SUCCESS 2 uib-bind attribute:",n,"with value:",o)()}catch{l("print","uibuilder:_uibAttrScanOne","\u{1F7E5}Error 2 uib-bind attribute:",n,"with value:",o)()}}n&&o?(e.setAttribute(n,o),n==="value"&&(e.value=o)):l("warn","uibuilder:_uibAttrScanOne","Invalid uib-bind attribute:",i.name,"with value:",o,"for element:",e)()}}))}async _uibAttrScanAll(e){Array.isArray(e)||(e=[e]),e.forEach(async t=>{let i=t.querySelectorAll(f(this,$e));i.length>0&&i.forEach(r=>{this._uibAttrScanOne(r)})})}_processFilesInput(e,t=!1){let i=[],r=e.files,n=r.length,o=0;for(let a of r){let u={};o++;for(let p in a)u[p]=a[p];u.tempUrl=window.URL.createObjectURL(a),i.push(u);let h={seq:o,seqCount:n};h.id=e.id,e.form&&(h.formId=e.form.id),h.tempUrl=u.tempUrl,h.data=e.dataset,t!==!0&&this.uploadFile(a,h)}return i}getElementAttributes(e){let t=["class","id","name"],i;try{i=Object.assign({},...Array.from(e.attributes,({name:r,value:n})=>{if(!t.includes(r))return{[r]:n}}))}catch{}return i}getElementClasses(e){let t;try{t=Array.from(e.classList)}catch{}return t}getElementCustomProps(e){let t={};return Object.keys(e).forEach(i=>{i.startsWith("_")||(t[i]=e[i])}),t}getFormElementValue(e){let t=null,i=null;switch(e.type){case"checkbox":case"radio":{t=i=e.checked;break}case"select-multiple":{t=Array.from(e.selectedOptions).map(r=>r.value);break}default:{e.value&&(t=e.value),e.checked&&(t=i=e.checked),e.valueAsNumber&&!isNaN(e.valueAsNumber)&&(t=e.valueAsNumber);break}}return{value:t,checked:i}}getFormElementDetails(e){if(!e.type)return l(1,"uibuilder:getFormElementDetails","Cannot get form element details as this is not an input type element")(),null;let t=this.returnElementId(e);if(!t)return l(1,"uibuilder:getFormElementDetails","Cannot get form element details as no id is present and could not be generated")(),null;let{value:i,checked:r}=this.getFormElementValue(e),n={id:t,name:e.name,valid:e.checkValidity(),type:e.type};if(i!==null&&(n.value=i),r!==null&&(n.checked=r),n.valid===!1){let o=e.validity;n.validity={badInput:o.badInput===!0?o.badInput:void 0,customError:o.customError===!0?o.customError:void 0,patternMismatch:o.patternMismatch===!0?o.patternMismatch:void 0,rangeOverflow:o.rangeOverflow===!0?o.rangeOverflow:void 0,rangeUnderflow:o.rangeUnderflow===!0?o.rangeUnderflow:void 0,stepMismatch:o.stepMismatch===!0?o.stepMismatch:void 0,tooLong:o.tooLong===!0?o.tooLong:void 0,tooShort:o.tooShort===!0?o.tooShort:void 0,typeMismatch:o.typeMismatch===!0?o.typeMismatch:void 0,valueMissing:o.valueMissing===!0?o.valueMissing:void 0}}return Object.keys(e.dataset).length>0&&(n.data=e.dataset),n}notify(e){return e.return?y.notification(e):(y.notification(e).then(t=>{l("info","Uib:notification","Notification completed event",t)()}).catch(t=>{l("error","Uib:notification","Notification error event",t)()}),null)}returnElementId(e){return e.id!==""?e.id:e.name!==""?"".concat(e.name,"-").concat(++ee(this,de)._):e.type?"".concat(e.type,"-").concat(++ee(this,de)._):"".concat(e.localName,"-").concat(++ee(this,de)._)}scrollTo(e,t){t||(t={}),!e||e==="top"||e==="start"?e="body":(e==="bottom"||e==="end")&&(e="body",t.block="end");let i=this.$(e);return i?(i.scrollIntoView(t),!0):!1}showMsg(e,t="body"){e===void 0&&(e=!f(this,ue)),C(this,ue,e);let i="Waiting for a message from Node-RED";return this.msg&&Object.keys(this.msg).length>0&&(i=this.syntaxHighlight(this.msg)),e===!1?y._uiRemove({components:["#uib_last_msg_wrap"]}):y._uiReplace({components:[{type:"div",id:"uib_last_msg_wrap",parent:t,attributes:{title:"Last message from Node-RED"},components:[{type:"button",attributes:{onclick:'uibuilder.copyToClipboard("msg")',class:"compact",style:"right:3em;"},slot:"\u{1F4CB}"},{type:"button",attributes:{onclick:"uibuilder.showMsg()",class:"compact",style:"right:.5em;"},slot:"\u26D4"},{type:"pre",id:"uib_last_msg",attributes:{class:"syntax-highlight"},slot:i}]}]}),e}showStatus(e,t="body"){if(e===void 0&&(e=!f(this,he)),C(this,he,e),e===!1)return y._uiRemove({components:["#uib_status"]}),e;let i={components:[{type:"div",id:"uib_status",parent:t,attributes:{title:"Current status of the uibuilder client",class:"text-smaller"},components:[{type:"table",components:[{type:"tbody",components:[]}]}]}]},r=i.components[0].components[0].components[0].components;return Object.values(f(this,Re)).forEach(n=>{r.push({type:"tr",attributes:{title:n.description},components:[{type:"th",slot:n.label},{type:"td",attributes:{"data-varType":n.var},slot:n.var==="version"?T._meta.version:JSON.stringify(this[n.var])}]})}),y._uiReplace(i),e}uiWatch(e,t="toggle",i=!0,r=!0){let n=document.querySelector(e);if(!n)return l("warn","uibuilder.module.js:uiWatch","CSS Selector '".concat(e,"' not found."))(),!1;(t==="toggle"||t===void 0||t===null)&&(f(this,V)[e]?t=!1:t=!0);let o=this;return t===!0?(f(this,V)[e]=new MutationObserver(function(a){let u=[];a.forEach(h=>{let p={type:h.type,oldValue:h.oldValue!==null?h.oldValue:void 0};h.addedNodes.length>0&&(p.addedNodes=[],h.addedNodes.forEach((m,b)=>{p.addedNodes.push(y.nodeGet(h.addedNodes[b]))})),h.removedNodes.length>0&&(p.removedNodes=[],h.removedNodes.forEach((m,b)=>{p.removedNodes.push(y.nodeGet(h.removedNodes[b]))})),h.type==="attributes"&&(p.attributeName=h.attributeName,p.newValue=h.target.attributes[h.attributeName].value),u.push(p)}),o._dispatchCustomEvent("uibuilder:domChange",u),i===!0&&o.send({_ui:{cssSelector:e,uiChanges:u},topic:o.topic||"DOM Changes for '".concat(e,"'")}),r===!0&&l("info","uibuilder.module.js:uiWatch","DOM Changes for '".concat(e,"'"),{uiChanges:u},{mutationList:a})()}),f(this,V)[e].observe(n,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),l("trace","uibuilder.module.js:uiWatch","Started Watching DOM changes for '".concat(e,"'"))()):(f(this,V)[e].disconnect(),delete f(this,V)[e],l("trace","uibuilder.module.js:uiWatch","Stopped Watching DOM changes for '".concat(e,"'"))()),t}watchDom(e){let t=document.documentElement,i=this;this._htmlObserver||(this._htmlObserver=new MutationObserver(function(){this.takeRecords(),i.saveHtmlCache()})),e===!0||e===void 0?(this._htmlObserver.observe(t,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),l("trace","uibuilder.module.js:watchDom","Started Watching and saving DOM changes")()):(this._htmlObserver.disconnect(),l("trace","uibuilder.module.js:watchDom","Stopped Watching and saving DOM changes")())}clearHtmlCache(){this.removeStore("htmlCache"),l("trace","uibuilder.module.js:clearHtmlCache","HTML cache cleared")()}restoreHtmlFromCache(){let e=this.getStore("htmlCache");if(e){let t=document.getElementsByTagName("html")[0];t.innerHTML=e,l("trace","uibuilder.module.js:restoreHtmlFromCache","Restored HTML from cache")()}else l("trace","uibuilder.module.js:restoreHtmlFromCache","No cache to restore")()}saveHtmlCache(){this.setStore("htmlCache",document.documentElement.innerHTML)}_ctrlMsgFromServer(e){if(e===null)e={};else if(typeof e!="object"){let t={};t["uibuilderCtrl:"+this._ioChannels.control]=e,e=t}switch(this._checkTimestamp(e),this.set("ctrlMsg",e),this.set("msgsCtrlReceived",++this.msgsCtrlReceived),l("trace","Uib:ioSetup:_ctrlMsgFromServer","Channel '".concat(this._ioChannels.control,"'. Received control msg #").concat(this.msgsCtrlReceived),e)(),e.uibuilderCtrl){case"shutdown":{l("info","Uib:ioSetup:".concat(this._ioChannels.control),'\u274C Received "shutdown" from server')(),this.set("serverShutdown",void 0);break}case"client connect":{l("trace","Uib:ioSetup:".concat(this._ioChannels.control),'Received "client connect" from server',e)(),l("info","Uib:ioSetup:".concat(this._ioChannels.control),"\u2705 Server connected. Version: ".concat(e.version,"\nServer time: ").concat(e.serverTimestamp,", Sever time offset: ").concat(this.serverTimeOffset," hours. Max msg size: ").concat(e.maxHttpBufferSize))(),T._meta.version.startsWith(e.version.split("-")[0])||l("warn","Uib:ioSetup:".concat(this._ioChannels.control),"Server version (".concat(e.version,") not the same as the client version (").concat(T._meta.version,")"))(),this.autoSendReady===!0&&l("trace","Uib:ioSetup:".concat(this._ioChannels.control,"/client connect"),"Auto-sending ready-for-content/replay msg to server"),this.maxHttpBufferSize=e.maxHttpBufferSize;break}case"get page meta":{this.set("pageMeta",e.payload);break}default:l("trace","uibuilder:ioSetup:".concat(this._ioChannels.control),"Received ".concat(e.uibuilderCtrl," from server"))}}_forThis(e){let t=!0;return e.pageName&&e.pageName!==this.pageName&&(l("trace","Uib:_msgRcvdEvents:_uib","Not for this page")(),t=!1),e.clientId&&e.clientId!==this.clientId&&(l("trace","Uib:_msgRcvdEvents:_uib","Not for this clientId")(),t=!1),e.tabId&&e.tabId!==this.tabId&&(l("trace","Uib:_msgRcvdEvents:_uib","Not for this tabId")(),t=!1),t}_msgRcvdEvents(e){if(this._dispatchCustomEvent("uibuilder:stdMsgReceived",e),e.topic&&this._dispatchCustomEvent("uibuilder:msg:topic:".concat(e.topic),e),!e._uib_processed_by){if(e._uib_processed_by="_msgRcvdEvents",e._uib){if(!this._forThis(e._uib))return;if(e._uib.reload===!0){l("trace","Uib:_msgRcvdEvents:_uib:reload","reloading")(),e._uib_processed_by="_msgRcvdEvents - reload",location.reload();return}if(e._uib.command){e._uib_processed_by="_msgRcvdEvents - remote command",this._uibCommand(e);return}e._uib.componentRef==="globalNotification"&&(e._uib_processed_by="_msgRcvdEvents - globalNotification",y.showDialog("notify",e._uib.options,e)),e._uib.componentRef==="globalAlert"&&(e._uib_processed_by="_msgRcvdEvents - globalAlert",y.showDialog("alert",e._uib.options,e))}if(e._ui){if(!this._forThis(e._ui))return;l("trace","Uib:_msgRcvdEvents:_ui","Calling _uiManager")(),e._uib_processed_by="_msgRcvdEvents - _ui",this._dispatchCustomEvent("uibuilder:msg:_ui",e),y._uiManager(e)}}}_send(e,t,i=""){t==null&&(t=this._ioChannels.client),t===this._ioChannels.client?(e=this.makeMeAnObject(e,"payload"),this.hasUibRouter()&&(e._uib||(e._uib={}),e._uib.routeId=this.uibrouter_CurrentRoute)):t===this._ioChannels.control&&(e=this.makeMeAnObject(e,"uibuilderCtrl"),Object.prototype.hasOwnProperty.call(e,"uibuilderCtrl")||(e.uibuilderCtrl="manual send"),e.from="client",this.hasUibRouter()&&(e.routeId=this.uibrouter_CurrentRoute)),e._socketId=this._socket.id,i===""&&this.originator!==""&&(i=this.originator),i!==""&&Object.assign(e,{_uib:{originator:i}}),Object.prototype.hasOwnProperty.call(e,"topic")||(this.topic!==void 0&&this.topic!==""?e.topic=this.topic:Object.prototype.hasOwnProperty.call(this,"msg")&&Object.prototype.hasOwnProperty.call(this.msg,"topic")&&(e.topic=this.msg.topic)),e._ui&&(e._ui.from="client",this.hasUibRouter()&&(e._ui.routeId=this.uibrouter_CurrentRoute));let r;t===this._ioChannels.client?(this.set("sentMsg",e),r=this.set("msgsSent",++this.msgsSent)):t===this._ioChannels.control&&(this.set("sentCtrlMsg",e),r=this.set("msgsSentCtrl",++this.msgsSentCtrl)),l("trace","Uib:_send"," Channel '".concat(t,"'. Sending msg #").concat(r),e)(),this._socket.emit(t,e)}_stdMsgFromServer(e){e=this.makeMeAnObject(e,"payload"),!(e._uib&&!this._forThis(e._uib))&&(e._ui&&!this._forThis(e._ui)||(this._checkTimestamp(e),this.set("msgsReceived",++this.msgsReceived),this._msgRcvdEvents(e),"_ui"in e&&!("payload"in e)||this.set("msg",e),l("info","Uib:ioSetup:stdMsgFromServer","Channel '".concat(this._ioChannels.server,"'. Received msg #").concat(this.msgsReceived,"."),e)()))}_uibCommand(e){var u;if(!e._uib||!e._uib.command){l("error","uibuilder:_uibCommand","Invalid command message received",{msg:e})(),e.payload=e.error="Invalid command message received",this.send(e);return}let t=e._uib.command;if(!f(this,qe).includes(t.trim())){l("error","Uib:_uibCommand","Command '".concat(t," is not allowed to be called externally"))();return}let i=e._uib.prop,r=e._uib.value,n=(u=e._uib.quiet)!=null?u:!1,o,a;switch(t){case"elementExists":{o=this.elementExists(i,!1),a='Element "'.concat(i,'" ').concat(o?"exists":"does not exist");break}case"get":{o=this.get(i);break}case"getManagedVarList":{i==="full"?o=this.getManagedVarList():o=Object.values(this.getManagedVarList());break}case"getWatchedVars":{i==="full"?o=this.getWatchedVars():o=Object.values(this.getWatchedVars());break}case"sendHtml":case"htmlSend":{o=this.htmlSend("",!1);break}case"include":{o=y.include(i,r);break}case"navigate":{let h;i?h=i:r&&(h=r),o=this.navigate(h);break}case"scrollTo":{o=this.scrollTo(i,r);break}case"set":{let h=!1,p=!1;e._uib.options&&e._uib.options.store&&(e._uib.options.store===!0&&(h=!0),e._uib.options.autoload===!0&&(p=!0)),o=this.set(i,r,h,p);break}case"showMsg":{o=this.showMsg(r,i);break}case"showStatus":{o=this.showStatus(r,i);break}case"uiGet":{o=y.uiGet(i,r);break}case"uiWatch":{o=this.uiWatch(i);break}case"watchUrlHash":{o=this.watchUrlHash(i);break}default:{l("warning","Uib:_uibCommand","Command '".concat(t,"' not yet implemented"))();break}}n!==!0&&(o===void 0&&(o="'".concat(i,"' is undefined")),Object(o).constructor===Promise?o.then(h=>(e.payload=e._uib.response=h,e.info=e._uib.info=a,e.topic||(e.topic=this.topic||"uib ".concat(t," for '").concat(i,"'")),this.send(e),!0)).catch(h=>{l(0,"Uib:_uibCommand","Error: ",h)()}):(e.payload=e._uib.response=o,e.info=e._uib.info=a,e.topic||(e.topic=this.topic||"uib ".concat(t," for '").concat(i,"'")),this.send(e)))}beaconLog(e,t){t||(t="debug"),navigator.sendBeacon("./_clientLog","".concat(t,"::").concat(e))}getPageMeta(){this.sendCtrl({uibuilderCtrl:"get page meta"})}htmlSend(e="",t=!0){let i="<!doctype html>\n".concat(document.documentElement.outerHTML),r={payload:i,length:i.length,topic:this.topic};return l("trace","Uib:htmlSend","Sending full HTML to Node-RED",r)(),t===!0&&this._send(r,this._ioChannels.client,e),i}logToServer(){this.sendCtrl({uibuilderCtrl:"client log message",payload:arguments,_socketId:this._socket.id,clientId:this.clientId,tabId:this.tabId,pageName:this.pageName,connections:this.connectedNum,lastNavType:this.lastNavType})}eventSend(e,t=""){if(this.$attrs){l("error","Uib:eventSend","`this` has been usurped by VueJS. Make sure that you wrap the call in a function: `doEvent: function (event) { uibuilder.eventSend(event) },`")();return}if(!e&&!event){l("warn","Uib:eventSend","Neither the domevent nor the hidden event properties are set. You probably called this function directly rather than applying to an on click event.")();return}if((!e||!e.constructor)&&(e=event),!e.constructor.name.endsWith("Event")||!e.currentTarget){l("warn","Uib:eventSend","ARGUMENT NOT A DOM EVENT - use data attributes not function arguments to pass data. Arg Type: ".concat(e.constructor.name),e)();return}e.preventDefault();let i=e.currentTarget,r=this.getElementCustomProps(i),n=this.getElementAttributes(i),o={},a;i.form?(a={id:this.returnElementId(i.form),valid:i.form.checkValidity()},Object.values(i.form).forEach((E,w)=>{if(["fieldset","object"].includes(E.type))return;let k=this.getFormElementDetails(E);k&&(E.type==="file"&&E.files.length>0&&(k.value=this._processFilesInput(E)),a[k.id]=k,o[k.id]=k.value)})):i.type==="file"&&(o=this._processFilesInput(i));let u=this.getElementClasses(i);Object.keys(i.dataset).length>0&&(o={...o,...i.dataset});let{value:h,checked:p}=this.getFormElementValue(i);h!==null&&(o.value=h),p!==null&&(o.checked=p);let m;Object.prototype.toString.call(i)==="[object Notification]"&&(o="notification-".concat(i.userAction),m={actions:i.actions,badge:i.badge,body:i.body,data:i.data,dir:i.dir,icon:i.icon,image:i.image,lang:i.lang,renotify:i.renotify,requireInteraction:i.requireInteraction,silent:i.silent,tag:i.tag,timestamp:i.timestamp,title:i.title,vibrate:i.vibrate});let b={payload:o,_ui:{type:"eventSend",id:i.id!==""?i.id:void 0,name:i.name!==""?i.name:void 0,slotText:i.textContent?i.textContent.substring(0,255):void 0,dataset:{...i.dataset},form:a,props:r,attribs:n,classes:u,notification:m,event:e.type,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,pointerType:e.pointerType,nodeName:i.nodeName,clientId:this.clientId,pageName:this.pageName,tabId:this.tabId}};l("trace","Uib:eventSend","Sending msg to Node-RED",b)(),this._send(b,this._ioChannels.client,t)}send(e,t=""){this._send(e,this._ioChannels.client,t)}sendRoom(e,t){this._socket.emit("uib-room-send",e,t)}joinRoom(e){this._socket.emit("uib-room-join",e)}leaveRoom(e){this._socket.emit("uib-room-leave",e)}sendCtrl(e){this._send(e,this._ioChannels.control)}sendCustom(e,t){this._socket.emit(e,t)}uploadFile(e,t){let i=new FileReader;i.onload=r=>{let n=r.target.result,o={topic:this.topic||"file-upload",payload:n,fileName:e.name,type:e.type,lastModified:e.lastModifiedDate,size:e.size,clientId:this.clientId,pageName:this.pageName,tabId:this.tabId,...t},a=this.maxHttpBufferSize-500;n.byteLength>=a&&(o.payload=void 0,o.error="File is too large to send. File size: ".concat(n.byteLength,". Max msg size: ").concat(a),l("error","Uib:uploadFile",o.error)()),this.send(o)},i.readAsArrayBuffer(e)}_getIOnamespace(){let e;if(e=this.cookies["uibuilder-namespace"],e===void 0||e===""){let t=window.location.pathname.split("/").filter(function(i){return i.trim()!==""});t.length>0&&t[t.length-1].endsWith(".html")&&t.pop(),e=t.pop(),l("trace","uibuilder.module.js:getIOnamespace","Socket.IO namespace found via url path: ".concat(e))()}else l("trace","uibuilder.module.js:getIOnamespace","Socket.IO namespace found via cookie: ".concat(e))();return this.url=e,e="/"+e,l("trace","uibuilder.module.js:getIOnamespace","Final Socket.IO namespace: ".concat(e))(),e}_checkConnect(e,t,i=1){if(navigator.onLine!==!1)return e||(e=this.retryMs),t||(t=this.retryFactor),l("trace","Uib:checkConnect","Checking connection.\nConnected: ".concat(this._socket.connected,".\nTimer: ").concat(f(this,S),". Depth: ").concat(i,". Delay: ").concat(e,". Factor: ").concat(t,".\nTransport: ").concat(this.currentTransport),this._socket)(),this._socket.connected===!0?(f(this,S)&&(window.clearTimeout(f(this,S)),C(this,S,null)),this.set("ioConnected",!0),this.set("socketError",null),!0):(this.set("ioConnected",!1),f(this,S)&&window.clearTimeout(f(this,S)),C(this,S,window.setTimeout(()=>{l("warn","Uib:checkConnect:setTimeout","Socket.IO reconnection attempt. Current delay: ".concat(e,". Depth: ").concat(i))(),this._socket.disconnect(),this._socket.connect(),C(this,S,null),this._checkConnect(e*t,t,i++)},e)),!1)}_onConnect(){this.currentTransport=this._socket.io.engine.transport.name,l("info","Uib:ioSetup","\u2705 SOCKET CONNECTED.\nConnection count: ".concat(this.connectedNum,", Is a Recovery?: ").concat(this._socket.recovered,".\nNamespace: ").concat(this.ioNamespace,"\nTransport: ").concat(this.currentTransport))(),this._dispatchCustomEvent("uibuilder:socket:connected",{numConnections:this.connectedNum,isRecovery:this._socket.recovered}),this._socket.io.engine.on("upgrade",()=>{this.currentTransport=this._socket.io.engine.transport.name,l("trace","Uib:_onConnect:onUpgrade","SOCKET CONNECTION UPGRADED.\nConnection count: ".concat(this.connectedNum,", Is a Recovery?: ").concat(this._socket.recovered,".\nNamespace: ").concat(this.ioNamespace,"\nTransport: ").concat(this.currentTransport))()}),setTimeout(()=>{this.currentTransport!=="websocket"&&l("error","Uib:Connection","Connected to Node-RED but NO SOCKET UPGRADE!\n\u27A1\uFE0F CHECK NETWORK and any PROXIES for issues. \u2B05\uFE0F\nConnection count: ".concat(this.connectedNum,", Is a Recovery?: ").concat(this._socket.recovered,".\nNamespace: ").concat(this.ioNamespace,"\nTransport: ").concat(this.currentTransport))()},2e3),this._checkConnect()}_onDisconnect(e){l("info","Uib:ioSetup:socket-disconnect","\u26D4 Socket Disconnected. Reason: ".concat(e))(),this._dispatchCustomEvent("uibuilder:socket:disconnected",e),this._checkConnect()}_ioSetup(){return J===void 0?(l("error","Uib:ioSetup","Socket.IO client not loaded, Node-RED comms will not work")(),!1):(this._socket&&(l("trace","Uib:ioSetup","Removing listeners in preparation for redoing Socket.IO connections")(),f(this,S)&&(window.clearTimeout(f(this,S)),C(this,S,null)),this._socket.close(),this._socket.offAny(),this._socket=void 0,this.set("ioConnected",!1)),this.socketOptions.path=this.ioPath,l("trace","Uib:ioSetup","About to create IO object. Transports: [".concat(this.socketOptions.transports.join(", "),"]"))(),this._socket=J(this.ioNamespace,this.socketOptions),this._connectGlobal(),this._socket.on("connect",this._onConnect.bind(this)),this._socket.on(this._ioChannels.server,this._stdMsgFromServer.bind(this)),this._socket.on(this._ioChannels.control,this._ctrlMsgFromServer.bind(this)),this._socket.on("disconnect",this._onDisconnect.bind(this)),this._socket.on("connect_error",e=>{navigator.onLine!==!1&&(l("error","Uib:ioSetup:connect_error","\u274C Socket.IO Connect Error. Reason: ".concat(e.message),e)(),this.set("ioConnected",!1),this.set("socketError",e),this._dispatchCustomEvent("uibuilder:socket:disconnected",e))}),this._socket.on("error",e=>{l("error","Uib:ioSetup:error","\u274C Socket.IO Error. Reason: ".concat(e.message),e)(),this.set("ioConnected",!1),this.set("socketError",e),this._dispatchCustomEvent("uibuilder:socket:disconnected",e)}),this._socket.io.engine.on("connection_error",e=>{l("error","Uib:ioSetup:io:engine:connection_error",e.code,e.message,e.context)()}),this._checkConnect(),!0)}_connectGlobal(){this._socketGlobal=J("/",this.socketOptions),this._socketGlobal.onAny((...e)=>{this.set("globalMsg",e.slice(0,-1))})}connect(){this._socket.connect()}disconnect(){this._socket.disconnect(),f(this,S)&&window.clearTimeout(f(this,S))}start(e){l("trace","Uib:start","Starting")(),f(this,Ne)&&this.cancelChange("msg",f(this,Ne)),this.started===!0&&l("info","Uib:start","Start function already called. Resetting Socket.IO and msg handler.")(),l("log","Uib:start","Cookies: ",this.cookies,"\nClient ID: ".concat(this.clientId))(),l("trace","Uib:start","ioNamespace: ",this.ioNamespace,"\nioPath: ".concat(this.ioPath))(),e&&(e.ioNamespace&&this.set("ioNamespace",e.ioNamespace),e.ioPath&&this.set("ioPath",e.ioPath),e.nopolling&&this.socketOptions.transports[0]==="polling"&&this.socketOptions.transports.shift());let[t]=performance.getEntriesByType("navigation");if(this.set("lastNavType",t.type),this.set("started",this._ioSetup()),this.started===!0?l("trace","Uib:start","Start completed. Socket.IO client library loaded.")():l("error","Uib:start","Start completed. ERROR: Socket.IO client library NOT LOADED.")(),this._watchHashChanges(),window.Vue){this.set("isVue",!0);try{this.set("vueVersion",window.Vue.version)}catch{}l("trace","Uib:start","VueJS is loaded. Version: ".concat(this.vueVersion))()}else l("trace","Uib:start","VueJS is not loaded.")();window.DOMPurify?(this.set("purify",!0),l("trace","Uib:start","DOMPurify is loaded.")()):l("trace","Uib:start","DOMPurify is not loaded.")(),window.markdownit?(this.set("markdown",!0),l("trace","Uib:start","Markdown-IT is loaded.")()):l("trace","Uib:start","Markdown-IT is not loaded.")(),this.onChange("msg",r=>{if(f(this,ue)===!0){let n=document.getElementById("uib_last_msg");n&&(n.innerHTML=this.syntaxHighlight(r))}}),this._uibAttrScanAll(document),new MutationObserver(this._uibAttribObserver.bind(this)).observe(document,{subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:this.uibAttribs,childList:!0}),this._dispatchCustomEvent("uibuilder:startComplete")}},X=new WeakMap,R=new WeakMap,L=new WeakMap,S=new WeakMap,Ne=new WeakMap,ue=new WeakMap,he=new WeakMap,Q=new WeakMap,de=new WeakMap,qe=new WeakMap,Ae=new WeakMap,Re=new WeakMap,V=new WeakMap,$e=new WeakMap,d(T,"_meta",{version:zt,type:"module",displayName:"uibuilder"}),T),nt=new st;window.uibuilder?l("error","uibuilder.module.js","`uibuilder` already assigned to window. Have you tried to load it more than once?"):window.uibuilder=nt;window.uib?l("warn","uibuilder.module.js","`uib` shortcut already assigned to window."):window.uib=nt;window.$?l("warn","uibuilder.module.js","Cannot allocate the global `$`, it is already in use. Use `uibuilder.$` or `uib.$` instead."):window.$=window.uibuilder.$;window.$$?l("warn","uibuilder.module.js","Cannot allocate the global `$$`, it is already in use. Use `uibuilder.$$` or `uib.$$` instead."):window.$$=window.uibuilder.$$;window.$ui?l("warn","uibuilder.module.js","Cannot allocate the global `$ui`, it is already in use. Use `uibuilder.$ui` or `uib.$ui` instead."):window.$ui=window.uibuilder.$ui;"on"in document||(document.on=function(s,e){this.addEventListener(s,e)});"on"in window||(window.on=function(s,e){this.addEventListener(s,e)});try{"query"in Element||(Element.prototype.query=function(s){return this.querySelector(s)}),"queryAll"in Element||(Element.prototype.queryAll=function(s){return this.querySelectorAll(s)}),"on"in Element||(Element.prototype.on=function(s,e){this.addEventListener(s,e)})}finally{}nt.start();customElements.define("uib-var",jt);customElements.define("uib-meta",Ft);customElements.define("apply-template",Vt);var fe,pe,me,Z,je,B,W,z,D=class D extends st{constructor(){super();v(this,fe,new Map);v(this,pe,null);v(this,me,new Set);v(this,Z,{});v(this,je,0);v(this,B,new Map);v(this,W,new Map);v(this,z,new Map);this._initExperimentalFeatures(),this._dispatchCustomEvent&&this._dispatchCustomEvent("uibuilder:experimentalReady",{features:D._experimentalMeta.features,version:D._experimentalMeta.version})}_initExperimentalFeatures(){this._initReactiveBinding(),this._initExperimentalAttributes(),this._initDialogSupport(),console.warn("[UibExperimental] Experimental mode activated. Features may change or be removed.",D._experimentalMeta),console.info("[UibExperimental] Available features:",D._experimentalMeta.features.split(","))}_initReactiveBinding(){C(this,pe,new MutationObserver(t=>{t.forEach(i=>{i.type==="attributes"&&i.target instanceof HTMLElement?this._handleReactiveAttributeChange(i.target,i.attributeName):i.type==="childList"&&i.addedNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE&&r instanceof HTMLElement&&this._scanForExperimentalAttributes(r)})})})),f(this,pe).observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["uib-bind","uib-on","uib-show","uib-text","uib-model"]})}_initExperimentalAttributes(){this._scanForExperimentalAttributes(document.body)}_initDialogSupport(){HTMLDialogElement||console.warn("[UibExperimental] Native dialog not supported. Consider adding a polyfill.")}createReactiveBinding(t,i,r={}){let n="".concat(t,":").concat(i),o={variable:t,selector:i,attribute:r.attribute||"textContent",transformer:r.transformer||(a=>a),twoWay:r.twoWay||!1,...r};f(this,fe).set(n,o),this._applyReactiveBinding(o),this.onChange(t,a=>{this._applyReactiveBinding(o,a)})}_applyReactiveBinding(t,i){let r=document.querySelectorAll(t.selector),n=i!==void 0?i:this.get(t.variable),o=t.transformer(n);r.forEach(a=>{t.attribute==="textContent"?a.textContent=o:t.attribute==="innerHTML"?a.innerHTML=o:t.attribute.startsWith("data-")?a.setAttribute(t.attribute,o):a[t.attribute]=o,t.twoWay&&a.tagName==="INPUT"&&a.addEventListener("input",u=>{this.set(t.variable,u.target.value)}),f(this,me).add(a)})}_handleReactiveAttributeChange(t,i){if(i==="uib-bind"){let r=t.getAttribute("uib-bind");if(r){let n=this.get(r);t.textContent=n}}else if(i==="uib-show"){let r=t.getAttribute("uib-show");if(r){let n=this.get(r);t instanceof HTMLElement&&(t.style.display=n?"block":"none")}}}_scanForExperimentalAttributes(t){t.querySelectorAll("[uib-bind]").forEach(n=>{let o=n.getAttribute("uib-bind");o&&this.createReactiveBinding(o,'[uib-bind="'.concat(o,'"]'))}),t.querySelectorAll("[uib-show]").forEach(n=>{let o=n.getAttribute("uib-show");o&&this.onChange(o,a=>{n.style.display=a?"block":"none"})})}async showExperimentalDialog(t){return new Promise(i=>{let r="exp-dialog-".concat(++ee(this,je)._),n=this._createDialog(r,t);f(this,Z)[r]=n;let o=a=>{delete f(this,Z)[r],n.remove(),t.onClose&&t.onClose(a),i(a)};n.addEventListener("close",()=>o(n.returnValue)),document.body.appendChild(n),n.showModal()})}_createDialog(t,i){let r=document.createElement("dialog");r.id=t,r.className="uib-experimental-dialog";let n="";if(i.title&&(n+='<header class="uib-dialog-header">\n                <h2>'.concat(i.title,'</h2>\n                <button type="button" class="uib-dialog-close" aria-label="Close">&times;</button>\n            </header>')),n+='<main class="uib-dialog-content">',i.template.trim().startsWith("<"))n+=i.template;else{let o=document.querySelector(i.template);o?n+=o.innerHTML:n+=i.template}return n+="</main>",i.template.includes("button")||(n+='<footer class="uib-dialog-footer">\n                <button type="button" value="cancel">Cancel</button>\n                <button type="button" value="ok" class="uib-primary">OK</button>\n            </footer>'),r.innerHTML=n,r.addEventListener("click",o=>{let a=o.target;a&&"matches"in a&&a.matches("button[value]")?(r.returnValue=a.value,r.close()):a&&"matches"in a&&a.matches(".uib-dialog-close")&&(r.returnValue="cancel",r.close())}),i.modal!==!1&&r.addEventListener("click",o=>{o.target===r&&(r.returnValue="cancel",r.close())}),r}closeAllDialogs(){Object.values(f(this,Z)).forEach(t=>{t.close()})}processTemplate(t,i={},r=null){let n=this._extractTemplateVariables(t);return r&&this._setupTemplateAutoUpdate(r,t,i,n),this._renderTemplate(t,i)}_extractTemplateVariables(t){let i=[],r=/\{\{([^}]+)\}\}/g,n;for(;(n=r.exec(t))!==null;){let o=n[1].trim();i.includes(o)||i.push(o)}return i}_setupTemplateAutoUpdate(t,i,r,n){f(this,z).set(t,i),f(this,W).set(t,{...r}),n.forEach(o=>{let a=o.split(".")[0];f(this,B).has(a)||f(this,B).set(a,new Set),f(this,B).get(a).add(t),this._ensureVariableListener(a)})}_ensureVariableListener(t){let i=this._propChangeCallbacks||{};i[t]&&i[t].some(n=>n.name==="_templateUpdateListener")||this.onChange(t,this._createTemplateUpdateListener(t))}_createTemplateUpdateListener(t){let i=r=>{let n=f(this,B).get(t);n&&n.forEach(o=>{let a=f(this,W).get(o);if(a){a[t]=r;let u=f(this,z).get(o);if(u){let h=this._renderTemplate(u,a);o.innerHTML=h}}})};return Object.defineProperty(i,"name",{value:"_templateUpdateListener"}),i}_renderTemplate(t,i){return t.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{let o=n.trim().split("."),a=i;for(let u of o)if(a=a==null?void 0:a[u],a===void 0)break;return a!==void 0?String(a):r})}updateTemplateData(t,i){let r=f(this,W).get(t);if(!r){console.warn("[UibExperimental] No template data found for element");return}Object.assign(r,i);let n=f(this,z).get(t);if(n){let o=this._renderTemplate(n,r);t.innerHTML=o}Object.entries(i).forEach(([o,a])=>{this.set(o,a)})}unbindTemplate(t){f(this,z).delete(t),f(this,W).delete(t),f(this,B).forEach(i=>{i.delete(t)})}applyTemplates(t={},i=!0){document.querySelectorAll("[uib-template]").forEach(n=>{let o=n.getAttribute("uib-template"),a=document.querySelector(o);if(a){let u=a.innerHTML;if(i){let h=this.processTemplate(u,t,n);n.innerHTML=h}else{let h=this._renderTemplate(u,t);n.innerHTML=h}}else console.warn('[UibExperimental] Template element not found for selector: "'.concat(o,'"'))})}applyAutoLayout(t,i={}){document.querySelectorAll(t).forEach(n=>{if(!(n instanceof HTMLElement))return;let o=i.type||"flex";o==="grid"?(n.style.display="grid",n.style.gridTemplateColumns=i.columns||"repeat(auto-fit, minmax(200px, 1fr))",n.style.gap=i.gap||"1rem"):o==="flex"&&(n.style.display="flex",n.style.flexWrap=i.wrap||"wrap",n.style.gap=i.gap||"1rem",n.style.justifyContent=i.justify||"space-between"),i.responsive!==!1&&this._addResponsiveLayout(n,o,i)})}_addResponsiveLayout(t,i,r){new ResizeObserver(o=>{for(let a of o){let u=a.contentRect.width;if(i==="grid"){let h=r.minColumnWidth||200,p=Math.floor(u/h)||1;t.style.gridTemplateColumns="repeat(".concat(p,", 1fr)")}else i==="flex"&&(u<(r.breakpoint||768)?t.style.flexDirection="column":t.style.flexDirection="row")}}).observe(t)}getExperimentalMeta(){return D._experimentalMeta}hasExperimentalFeature(t){return D._experimentalMeta.features.split(",").includes(t)}setExperimentalDebug(t=!0){t?(console.info("[UibExperimental] Debug mode enabled"),typeof window<"u"&&(window.uibExpDebug={bindings:f(this,fe),elements:f(this,me),dialogs:f(this,Z)})):typeof window<"u"&&"uibExpDebug"in window&&delete window.uibExpDebug}cleanup(){var t;(t=f(this,pe))==null||t.disconnect(),this.closeAllDialogs(),f(this,me).clear(),f(this,fe).clear(),f(this,B).clear(),f(this,W).clear(),f(this,z).clear(),console.info("[UibExperimental] Cleanup completed")}};fe=new WeakMap,pe=new WeakMap,me=new WeakMap,Z=new WeakMap,je=new WeakMap,B=new WeakMap,W=new WeakMap,z=new WeakMap,d(D,"_experimentalMeta",{version:"7.5.0-experimental",features:"reactive-binding,enhanced-dialogs,auto-layout,template-engine",warning:"Experimental features - subject to change or removal"});var ot=D,Kt=new ot;var Hs=Kt;typeof window<"u"&&(window.uibExperimental=Kt);export{ot as UibExperimental,Hs as default,Kt as uibExperimental};
/**
 * @kind module
 * @module reactive
 * @description Reactive proxy implementation for uibuilder (Loosely based on Vue.js v3 reactivity)
 * @license Apache-2.0
 * @author Julian Knight (Totally Information)
 * @copyright (c) 2025 Julian Knight (Totally Information)
 */
/**
 * @kind module
 * @module uibuilder
 * @description The client-side Front-End JavaScript for uibuilder in HTML Module form
 *   It provides a number of global objects that can be used in your own javascript.
 *   see the docs folder `./docs/uibuilder.module.md` for details of how to use this fully.
 *
 *   Please use the default index.js file for your own code and leave this as-is.
 *   See Uib._meta for client version string
 * @license Apache-2.0
 * @author Julian Knight (Totally Information)
 * @copyright (c) 2022-2025 Julian Knight (Totally Information)
 */
/**
 * @kind module
 * @module experimental
 * @description Experimental extensions to the uibuilder client library for testing future features
 *   This module extends the Uib class with experimental functionality that may be included
 *   in future releases. Use at your own risk as these features may change or be removed.
 * @license Apache-2.0
 * @author Julian Knight (Totally Information)
 * @copyright (c) 2025 Julian Knight (Totally Information)
 */
//# sourceMappingURL=experimental.mjs.map
